12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
+/- Click and see the code that is about the article.
#includeint main () { int counter,first,second=0,third=0,last,finally; for (counter=1;counter<=100;counter++) { first=counter*counter; second +=first; } printf("First : %d\n",second); for (counter=1;counter<=100;counter++) { third+=counter; last=third*third; } printf("Second : %d\n",last); finally=last-second; printf("Diffirence : %d\n",finally); }

No comments:
Post a Comment