AtCoder Beginner Contest 055: B - Training Camp
LargeInt
とIntInf
の違いとは。
implementation
fun fact(n) =
let
fun go(0, acc) = acc
| go(n, acc) = go(n-1, n * acc mod 1000000007)
in
Int.fromLarge(go(Int.toLarge(n), 1))
end
fun readInt() = TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn
val SOME n = readInt()
val () = print(Int.toString(fact(n)) ^ "\n")