http://projecteuler.net/index.php?section=problems&id=20
他の数値型から多倍長整数型への変換は次のようにします。
let n = 1 printfn "%A" (System.Numerics.BigInteger n)
ただ、これだとちょっと名前が長いのが困ります。こう書けば短く済みます。
open System.Numerics let n = 1 printfn "%A" (BigInteger n)
問題は階乗を計算するだけです。
open System.Numerics let rec factorial n = if n = 0 then 1I else (BigInteger n) * (factorial (n - 1)) let rec digits n = if n = 0I then [] else (digits (n / 10I)) @ [int (n % 10I)] printfn "%d" (List.sum (digits (factorial 100)))