samskivert: Euler 020

18 January 2008

Problem 020:

object Euler20 extends Application {
  def fact (n: BigInt): BigInt = if (n == 0) 1 else n * fact(n - 1)
  println(fact(100).toString().foldRight(0)((a, b) => (b + (a - '0'))));
}

Another one where BigInt does all the heavy lifting.

©1999–2022 Michael Bayne