Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package net.sf.cotelab.euler;

A solution for Project Euler Problem 6. The problem statement is here.

Author(s):
Al Cote'
 
 public class Problem06 {

Parameters:
args
	public static void main(String[] args) {
		int square = squareOfSum();
		int sum = sumOfSquares();
		int difference = square - sum;
		..println("squareOfSum = " + square);
		..println("sumOfSquares = " + sum);
		..println("difference = " + difference);
	}
	private static int squareOfSum(int n) {
		int sum = n * (n + 1) / 2;
		int square = sum * sum;
		return square;
	}
	private static int sumOfSquares(int n) {
		int sum = n * (n + 1) * ((2 * n) + 1) / 6;
		return sum;
	}
	public static final int N = 100;
New to GrepCode? Check out our FAQ X