public class ProjectEuler{
static int n = 100;
public static void main(String []args){
System.out.println(differencehelper());
}
static int sumsquare(int n){
int sum = 0 ;
sum = (n*(n+1)(2*n+1))/6;
return sum;
}
static int squaresum(int n){
int sum = 0;
sum = (n(n+1))/2;
return (sum *sum);
}
static int differencehelper(){
return squaresum(n) - sumsquare(n);
}
}
Easy Java Solution using Gauss' Formula Hope you liked it ;)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
public class ProjectEuler{
static int n = 100;
public static void main(String []args){
System.out.println(differencehelper());
}
Easy Java Solution using Gauss' Formula Hope you liked it ;)