File: Fib.hs

package info (click to toggle)
haskell-doctest-parallel 0.3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 652 kB
  • sloc: haskell: 3,241; makefile: 6; ansic: 4
file content (20 lines) | stat: -rw-r--r-- 330 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module TestCombinedExample.Fib where

-- | Calculate Fibonacci number of given 'Num'.
--
-- First let's set `n` to ten:
--
-- >>> let n = 10
--
-- And now calculate the 10th Fibonacci number:
--
-- >>> fib n
-- 55
--
-- >>> let x = 10
-- >>> x
-- 10
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)