project-euler/problem6.c

19 lines
422 B
C

#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
int difference = 0;
int squareOfSum = 0;
int sumOfSquares = 0;
for (int i = 1; i < 101; i++)
{
squareOfSum += i;
sumOfSquares += i*i;
}
squareOfSum *= squareOfSum;
difference = squareOfSum - sumOfSquares;
printf("The difference between the sum of the squares of the first one hundred natural numbers and the square of the sum is: %d\n", difference);
}