Q. Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
Sol:
I think problem is also one of the easiest problems here.
The problem can be easily solved through basic knowledge of Arithmetic-Geometric Progression....
We know that sum of squares of numbers from 1 to n is n(n+1)(2n+1)/6 and sum of the numbers from 1 to n is n(n+1)/2.
So, the result can be formulated into an expression
Difference= (n(n+1)/2) ^ 2 - n(n+1)(2n+1)/6 = n(n+1)( 3(n^2) - n -2 ) / 12
Now all that remains is calculation....... :D
Please post your comments...
Suggestion for better algorithms are always welcome.....
Sunday, January 24, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment