Posted By

theobriscoe on 12/18/08


Tagged

project Euler


Versions (?)

Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000)


 / Published in: Groovy
 

  1. def sumPowerSeries(int n){
  2. BigInteger sum = 0
  3. BigInteger seriesVal = 0
  4.  
  5. for (int index = 1; index < n+1; index++) {
  6. seriesVal = index
  7. sum = sum + seriesVal.pow(index)
  8. //println " " + index + " " + sum
  9. }
  10. return sum
  11. }

Report this snippet  

You need to login to post a comment.