You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
330 B
Forth
15 lines
330 B
Forth
3 years ago
|
// Modules
|
||
|
open System
|
||
|
|
||
|
// Recursive definition of Fibonacci numbers
|
||
|
let rec fib n =
|
||
|
match n with
|
||
|
| 0 -> 0
|
||
|
| 1 -> 1
|
||
|
| _ -> fib (n-1) + fib (n-2)
|
||
|
|
||
|
// Read from stdin and print result
|
||
|
printfn "Inserisci l'indice del numero di fibonacci che vuoi calcolare:\n"
|
||
|
let i = Console.ReadLine() |> int
|
||
|
printfn "%A" (fib (i))
|