Last active
September 18, 2016 18:42
-
-
Save celsojr/04a3e18341c48b1df70d2482208183a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// F# calculating the factorial in imperative approach programming. | |
let Fact n = | |
let mutable x = n | |
let mutable y = 1 | |
while x > 0 do | |
y <- y * x | |
x <- (x - 1) | |
y | |
for i in 0 .. 10 do | |
printfn "%02d! = %d" i (Fact i) | |
(* the output | |
00! = 1 | |
01! = 1 | |
02! = 2 | |
03! = 6 | |
04! = 24 | |
05! = 120 | |
06! = 720 | |
07! = 5040 | |
08! = 40320 | |
09! = 362880 | |
10! = 3628800 | |
*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment