parent
bbab1294fc
commit
ebaee399f6
Binary file not shown.
@ -0,0 +1,26 @@ |
|||||||
|
#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; |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
#define true 1 |
||||||
|
#define false 0 |
||||||
|
#define boolean char |
||||||
|
struct String{ |
||||||
|
int length; |
||||||
|
char*str; |
||||||
|
}; |
Loading…
Reference in new issue