Cleanup, update
This commit is contained in:
@@ -8,7 +8,14 @@ let rec fib n =
|
||||
| 1 -> 1
|
||||
| _ -> fib (n-1) + fib (n-2)
|
||||
|
||||
let rec fibSmart n =
|
||||
match n with
|
||||
| n when n < 0 -> failwith (sprintf "Error: %d is less than 0" n)
|
||||
| (0|1) -> n
|
||||
| _ -> fibSmart (n-1) + fibSmart (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))
|
||||
printfn "%A" (fibSmart (i))
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user