Identity Interface I should know better


26
Apr/11
0

F# Baby Steps – Fibonacci

 

F# is the kind of language that can really energize someone who is excited about just sitting down and powering out a solution.

Here is an example of how to sum some fibonacci numbers.

 

let rec fibonacci n = 

    if n < 2 then 1 

    else fibonacci (n-2) + fibonacci(n-1)

 

//create a recursive function called fibonacci

//that takes the parameter n 

// if n < 2 then 1  so this is the base case.

//else fib (n - 2) + fib (n - 1)

 

printfn "fibonacci = %A" (fibonacci 10)

Filed under: code
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


No trackbacks yet.