Project Euler – Problem 48

Problem 49: Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + … + 1000^1000.

import java.math.BigInteger;

class runner
{
	public static void main (String[] args) throws java.lang.Exception
	{
		long time = System.currentTimeMillis();

		BigInteger sum = new BigInteger("0");
		for(int i=1;i<=1000;i++){
			BigInteger cur = new BigInteger(""+i);
			sum = sum.add(cur.pow(i));
		}
		
		String r = sum.toString();
		System.out.println(r.substring(r.length()-10));
		
		System.out.println("time: "+(System.currentTimeMillis() - time));
	}
}