Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Created December 29, 2019 06:19
Show Gist options
  • Save gsscoder/fdd403e14624ace6419a0f298a7dbbbc to your computer and use it in GitHub Desktop.
Save gsscoder/fdd403e14624ace6419a0f298a7dbbbc to your computer and use it in GitHub Desktop.
F# script to calculate factorial of a number
// $ 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