samskivert: Euler 048

11 August 2008

Problem 048:

object Euler48 extends Application {
  println( => BigInt(a).pow(a)).reduceRight(_+_) % BigInt(10).pow(10))

The Right Thing ™ here was to not rely on the magic of BigInt, but to do the addition modulo 10^10 as well as to compute the powers modulo 10^10, but laziness and the allure of a one line solution won out in the end.

©1999–2022 Michael Bayne