题目:
The sum of the squares of the first ten natural numbers is,
1
2
+ 2
2
+ ... + 10
2
= 385The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)
2
= 55
2
= 3025Hence 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.
翻译:
前10个自然数的平方的和是,1
2 + 2 2 + ... + 10 2 = 385而他们的和的平方是,(1 + 2 + ... + 10)
2 = 55 2 = 3025他们的差就是3025
385 =
2640。
找出前100个自然数的这种差。
解题思路:
说实话,这题和第一题的难度一样低,直接上代码。
代码: