[Project Euler]Problem 6
2011-05-06 17:14
417 查看
Problem 6:
The sum of the squares of the first ten natural numbers is,
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 方法二
The sum of the squares of the first ten natural numbers is,
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 方法二
def f2(n): return ((n+1)*n*(n-1)*(3*n+2))//12
相关文章推荐
- [Project Euler] Problem 60 Deep First, Milestone, New Start
- 【Project Euler】【Problem 6】Sum square difference
- [Project Euler]加入欧拉 Problem 5
- [Project Euler] Problem 9
- [Project Euler] Problem 24
- [Project Euler] Problem 27
- Project Euler:Problem 16 Power digit sum
- Project Euler:Problem 47 Distinct primes factors
- Project Euler:Problem 59 XOR decryption
- Project Euler:Problem 66 Diophantine equation
- Project Euler:Problem 82 Path sum: three ways
- Project Euler__problem 9
- Project Euler – Problem 17
- [Project Euler] Problem 49
- [Project Euler] Problem 51
- 【Project Euler】【Problem 7】10001st prime
- [Project Euler]加入欧拉 Problem 6
- [Project Euler] Problem 10
- [Project Euler] Problem 28
- [Project Euler]Problem 7