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.

这第六题python实现最简单吧

  1. max1 = 100
  2.  
  3. sum1 = 0
  4. sum2 = 0
  5. for i in range(1,max1+1):
  6. sum1 += i**2
  7.  
  8. sum2 = ((1+max1)*max1/2)**2
  9. print(sum2-sum1)

  

Problem 6: Sum square difference的更多相关文章

  1. (Problem 6)Sum square difference

    Hence the difference between the sum of the squares of the first ten natural numbers and the square ...

  2. projecteuler Sum square difference

    The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of ...

  3. Sum square difference

    简单: e sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square o ...

  4. (Problem 57)Square root convergents

    It is possible to show that the square root of two can be expressed as an infinite continued fractio ...

  5. Project Euler 44: Find the smallest pair of pentagonal numbers whose sum and difference is pentagonal.

    In Problem 42 we dealt with triangular problems, in Problem 44 of Project Euler we deal with pentago ...

  6. Porject Euler Problem 6-Sum square difference

    我的做法就是暴力,1+...+n 用前n项和公式就行 1^2+2^2+....+n^2就暴力了 做完后在讨论版发现两个有趣的东西. 一个是 (1+2+3+...+n)^2=(1^3)+(2^3)+(3 ...

  7. [LeetCode&Python] Problem 404. Sum of Left Leaves

    Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two l ...

  8. [LeetCode&Python] Problem 530. Minimum Absolute Difference in BST

    Given a binary search tree with non-negative values, find the minimum absolute difference between va ...

  9. [LeetCode&Python] Problem 371. Sum of Two Integers

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...

随机推荐

  1. Jmeter 常见错误

    常见错误 https://testerhome.com/topics/10950 接口测试 https://blog.csdn.net/github_27109687/article/details/ ...

  2. python多环境下虚拟环境的搭建和使用

    由于开发环境要求,或者实际需要.经常会出现python2.7和python3.x共存下的开发环境问题.虚拟环境的搭建可以很好的隔离Projects的开发环境. 1.首先解决python2.7和pyth ...

  3. Spring定时任务@Scheduled注解使用方式

    1.开篇 spring的@Scheduled定时任务相信大家都是十分熟悉.最近在使用过程中发现了一些问题,写篇文章,和大家分享一下.结论在最后,不想看冗长过程的小伙伴可以直接拉到最后看结论. 2.简单 ...

  4. MySQL优化查询 5.7版本

    1. 变更参数 : query_cache_type 如果何配置查询缓存: query_cache_type 这个系统变量控制着查询缓存工能的开启的关闭.query_cache_type=0时表示关闭 ...

  5. acure使用

    打开,选择用IE浏览器,如果选择Chrome浏览器会提示让安装插件

  6. SpringBoot+mybatis:报错Fri Oct 19 14:29:24 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requiremen

    报错:Fri Oct 19 14:29:24 CST 2018 WARN: Establishing SSL connection without server's identity verifica ...

  7. PHP json_decode为什么将json字符串转成数组是对象格式?

    eg. $a='[{\"img\":\"/uploads/agency/carimgs/5/15515954778091.jpg\"},{\"img\ ...

  8. Git更改用户名与回退操作

    1. 更改本地用户名和邮箱 git config --global user.name "Your_username" git config --global user.email ...

  9. 给MS的意见

    2017-02-27 WPF的中文注释文档翻译得很烂.太多了,列举不过来. 这个是 System.Threading.Tasks.Task.Exception: 获取导致 System.Aggrega ...

  10. windows和linux环境下keras的模型框架可视化

    1.简介 keras提供了模型可视化模块,下面讲解下安装教程和简易教程. 2.安装教程 2.1windows环境下的安装 2.1.1安装指定模块 pip install pydot-ng pip in ...