# Write a program to find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

**Updated:**June 20, 2021 —

**Training Time:**1 Minute

Overseen by: Archangel Macsika

All Training Resources

Scroll for more menu list

**Topic:**Generic - Java Programming

**Difficulty:** Easy.

**Companies who previously asked this:** -.

**Objective:** Write a program to find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

**Input:** None.

**Expected Output:** Find out.

### Sikademy Solution

```
package sikademy;
/**
*
* @author Archangel Macsika
*/
import java.util.logging.Logger;
// This class finds the difference between the sum of square of first one hundred natural numbers and the square of sum of first hundred natural numbers.
public class SumSquareDifference {
private static final Logger LOG=Logger.getLogger(SumSquareDifference.class.getName());
public static void main(String[] args) {
LOG.info("Into main class");
int sumOfSquares=0;
int squareOfSum=0;
int sumOfNaturalNumers=0;
for(int i=0;i<=100;i++){
sumOfSquares+=i*i;
sumOfNaturalNumers+=i;
}
LOG.info("The difference is : "+ (int)(Math.pow(sumOfNaturalNumers, 2)-sumOfSquares));
}
}
```