Skip to main content

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems.

For problem #48, coming from a Python background, my solution is the following one-liner:

print ( (1 to 1000).map(i => BigInt(i).pow(i)).sum % BigInt(10).pow(10) )

Is this idiomatic? Is there a simpler/more readable solution?

Thanks a lot for your input.

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems.

For problem #48, coming from a Python background, my solution is the following one-liner:

print ( (1 to 1000).map(i => BigInt(i).pow(i)).sum % BigInt(10).pow(10) )

Is this idiomatic? Is there a simpler/more readable solution?

Thanks a lot for your input.

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems.

For problem #48, coming from a Python background, my solution is the following one-liner:

print ( (1 to 1000).map(i => BigInt(i).pow(i)).sum % BigInt(10).pow(10) )

Is this idiomatic? Is there a simpler/more readable solution?

Tweeted twitter.com/#!/StackCodeReview/status/251335838263296000
Source Link
jjt
  • 163
  • 5

Solving Project Euler problem #48 in Scala

I'm trying to learn some Scala and decided to try to tackle some Project Euler problems.

For problem #48, coming from a Python background, my solution is the following one-liner:

print ( (1 to 1000).map(i => BigInt(i).pow(i)).sum % BigInt(10).pow(10) )

Is this idiomatic? Is there a simpler/more readable solution?

Thanks a lot for your input.