blob: 7b7034288c127dfd3ba6a8b7d513f641aca1205a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
module Examples where
-- | Fibonacci number of given 'Integer'.
--
-- Examples:
--
-- >>> fib 5
-- 5
-- >>> fib 10
-- 55
--
-- >>> fib 10
-- 55
--
-- One more Example:
--
-- >>> fib 5
-- 5
--
-- One more Example:
--
-- >>> fib 5
-- 5
--
-- Example with an import:
--
-- >>> import Data.Char
-- >>> isSpace 'a'
-- False
--
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)
|