Sort 57 Discussions, By:
Please Login in order to post a comment
Easy in Haskell
fib n = fibs !! (n -1) where
fibs = 0:1:[(a+b)|(a, b) <- zip fibs (tail fibs)]
Why utilize this (off-base) decision of records? The Fibonacci numbers should begin with f(0) = 0, f(1) = 1, if by some stroke of good luck for tasteful reasons,monitoredged similar to the gcd-property. Gratitude for the video interface btw.
let rec f n =
match n with
| 1 -> 0
| 2 -> 1
| n -> f (n - 1) + f (n - 2)
let main argv =
Console.ReadLine() |> int |> f |> Console.WriteLine
This is a great source here.
I am a new learner here , can you help me.