Skip to content

Instantly share code, notes, and snippets.

@LuxXx
Created April 14, 2017 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuxXx/ad2bddea71fea9cc77f59e1efe411895 to your computer and use it in GitHub Desktop.
Save LuxXx/ad2bddea71fea9cc77f59e1efe411895 to your computer and use it in GitHub Desktop.
Project Euler - Problem 6
package euler;
public class Square {
public static void main(String[] args) {
System.out.println(sum2(100) - sum(100));
}
public static int sum(int n) {
return n*(n+1)*(2*n+1)/6;
}
public static int sum2(int n) {
return n*n*(n+1)*(n+1)/4;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment