您的位置:首页 > 其它

[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 方法二

def f2(n):
return ((n+1)*n*(n-1)*(3*n+2))//12
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: