diff options
Diffstat (limited to 'ghc/misc/examples/nfib/nfibJ.hs')
-rw-r--r-- | ghc/misc/examples/nfib/nfibJ.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ghc/misc/examples/nfib/nfibJ.hs b/ghc/misc/examples/nfib/nfibJ.hs new file mode 100644 index 0000000000..c622e5c6e1 --- /dev/null +++ b/ghc/misc/examples/nfib/nfibJ.hs @@ -0,0 +1,10 @@ +module Main where + +main = print (nfib 28) + +nfib :: Integer -> Integer + +nfib n | n <= 1 = 1 + | otherwise = (n1 + n2 + 1) + where n1 = nfib (n-1) + n2 = nfib (n-2) |