Skip to content

Instantly share code, notes, and snippets.

@pokutuna
Created September 16, 2012 05:52
Show Gist options
  • Save pokutuna/3731184 to your computer and use it in GitHub Desktop.
Save pokutuna/3731184 to your computer and use it in GitHub Desktop.
def sumOfDigits(num: BigInt): Int = num.toString.map(_.getNumericValue).sum
val result = ( for (a <- 1 until 100; b <- 1 until 100) yield sumOfDigits(BigInt(a).pow(b)) ).max
println(result) // => 972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment