Created
September 2, 2016 04:09
-
-
Save anonymous/dcb4f83dbbc543394b64ef7eb5bb0cf8 to your computer and use it in GitHub Desktop.
F# Factorial - Pattern Matching and Recursion
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
let factorial n = | |
let rec factorial' n acc = | |
match n with | |
| 0 -> acc | |
| _ -> factorial' (n - 1) (acc * n) | |
factorial' n 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample Usage:
[0..10] |> List.map factorial