module Solutions.P29 (fibonacci) where
fibonacci :: Integral a => a -> a
fibonacci :: forall a. Integral a => a -> a
fibonacci a
1 = a
1
fibonacci a
2 = a
1
fibonacci a
n | a
n a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
2 = a -> a -> a -> a
forall a. Integral a => a -> a -> a -> a
fib a
1 a
1 a
n
| Bool
otherwise = a
forall a. HasCallStack => a
undefined
fib :: Integral a => a -> a -> a -> a
fib :: forall a. Integral a => a -> a -> a -> a
fib a
k a
k' a
3 = a
k a -> a -> a
forall a. Num a => a -> a -> a
+ a
k'
fib a
k a
k' a
n = a -> a -> a -> a
forall a. Integral a => a -> a -> a -> a
fib a
k' (a
ka -> a -> a
forall a. Num a => a -> a -> a
+a
k') (a
na -> a -> a
forall a. Num a => a -> a -> a
-a
1)