import java.util.ArrayList;
import java.util.List;
/**
 * Created by Crystal on 6/29/2015.
 */
public class Program {
    public static void main(String[] args) {
        // Project Euler #6: Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum
        // Starting value, set x to 100
        long start = System.nanoTime();
        int x = 100;
        int sumOfSquares = (x * (x + 1) * (2 * x + 1)) / 6;
        int sum = 0;
        for (int i = 1; i <= x; i++)sum += i;
        long stop = System.nanoTime();
        System.out.println(sum*sum - sumOfSquares + " is the solution calculated in a time of " + (stop - start) / 1000000 + "ms");
    }
}
25164150 is the solution calculated in a time of 0ms.
 
 
 
