Created
December 29, 2019 06:19
-
-
Save gsscoder/fdd403e14624ace6419a0f298a7dbbbc to your computer and use it in GitHub Desktop.
F# script to calculate factorial of a number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ dotnet fsi factorial.fsx 10 | |
// 3628800 | |
let rec factorial n : int64 = | |
match n with | |
| 0L -> 1L | |
| n -> n * factorial(n - 1L) | |
printfn "%d" (factorial (fsi.CommandLineArgs.[1] |> int64)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment