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


/ Published in: Groovy
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.