In this post we are going to see how to create a Fibonacci series in F#. we can create the fibonacci in simple steps.
Press Alt+enter by select the code and enter the Fib 5 in Interactive window.
> fib 6 ;;
val it : int = 8
> fib 20 ;;
val it : int = 6765
From this sample you see how to create the Fibonacci.
open System
let rec fib n =
match n with
| 1 -> 1
| 2 -> 1
| n -> fib(n -
1) + fib(n - 2)
> fib 6 ;;
val it : int = 8
> fib 20 ;;
val it : int = 6765
From this sample you see how to create the Fibonacci.
No comments:
Post a Comment