fork download
  1. open System
  2.  
  3. let toBigInt (n: int) = bigint(n) // Convert an "int" to a "bigint".
  4.  
  5. // Factorial with bigint support:
  6. let fac n =
  7. [1..n]
  8. |> List.map toBigInt
  9. |> List.reduce (*)
  10.  
  11. let printFacTable n =
  12. let listNum = [1 .. n]
  13. let listFac = listNum |> List.map fac
  14. let numFacPair = List.zip listNum listFac
  15. for (k, v) in numFacPair
  16. do printfn "%-2d ! = %A" k v
  17.  
  18. printFacTable 12
Success #stdin #stdout 0.19s 26384KB
stdin
Standard input is empty
stdout
1  ! = 1
2  ! = 2
3  ! = 6
4  ! = 24
5  ! = 120
6  ! = 720
7  ! = 5040
8  ! = 40320
9  ! = 362880
10 ! = 3628800
11 ! = 39916800
12 ! = 479001600