Press CTRL+C or CMD+C to copy the selected text and close this dialog.
Tweet
26 people like it. Like the snippet!
Calculates the factorial for positive integers
1: 2: 3: 4: 5: 6: 7:
// calculates the factorial: // n! = 1 * 2 * 3 * ... * n // the factorial only exists for positive integers let rec factorial n = match n with | 0 | 1 -> 1 | _ -> n * factorial (n - 1)