For Project Euler progression and fun
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ProjectEuler/src/main.c

26 lines
756 B

#include <stdio.h>
#include "utils.h"
/*
The sum of the squares of the first ten natural numbers is,
The square of the sum of the first ten natural numbers is,
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is .
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
https://projecteuler.net/problem=6
*/
int main(int argc,char**argv) {
int sumOfSquares=0,squareOfSum=0;
for (int i=0;i<=100;i++) {
sumOfSquares+=i*i;
}
for (int i=0;i<=100;i++) {
squareOfSum+=i;
}
squareOfSum*=squareOfSum;
printf("%d - %d = %d",squareOfSum,sumOfSquares,squareOfSum-sumOfSquares);
return 0;
}