project Euler第六题

来源:互联网 发布:胡一天淘宝内衣模特 编辑:程序博客网 时间:2024/04/29 09:37

题目:

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 − 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.


算法:


#!usr/bin/env python#coding=utf-8a = 100*(100+1)*(200+1)/6b = (1+100)*50b = b**2print b-a

结果:

25164150


这个题没啥说的,就是两个数学公式