Created
April 14, 2017 11:40
-
-
Save LuxXx/ad2bddea71fea9cc77f59e1efe411895 to your computer and use it in GitHub Desktop.
Project Euler - Problem 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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