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实现最简单吧

max1 = 100

sum1 = 0
sum2 = 0
for i in range(1,max1+1):
sum1 += i**2 sum2 = ((1+max1)*max1/2)**2
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. Tensorflow训练和预测中的BN层的坑

    以前使用Caffe的时候没注意这个,现在使用预训练模型来动手做时遇到了.在slim中的自带模型中inception, resnet, mobilenet等都自带BN层,这个坑在<实战Google ...

  2. Valotile关键字详解

    在了解valotile关键字之前.我们先来了解其他相关概念. 1.1  java内存模型: 不同的平台,内存模型是不一样的,我们可以把内存模型理解为在特定操作协议下,对特定的内存或高速缓存进行读写访问 ...

  3. js把某个div或其他元素用图片的形式导出或下载

    很多时候需要用到把页面上的某个块元素用图片的形式导出来,例如导出一些表格构成的单据 思路:把指定的html内容转换成canvas,然后再转换成图片 这里推荐使用这两个库 <script src= ...

  4. ssh连接所生成的known_hosts出现的问题

    问题现场及解析 用OpenSSH的人都知ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts.当下次访问相同计算机时,OpenSSH会核对公钥.如果 ...

  5. python实现将base64编码的图片下载到本地

    # -*- coding:utf-8 -*- #!python3 import os import base64 sss ="""base64的编码"" ...

  6. 集训队日常训练20181201 E 1005 : 小蝌蚪

    时间限制(普通/Java):500MS/1500MS     内存限制:65536KByte总提交: 25            测试通过:5 描述 有 n 个装着小蝌蚪的水缸排成一排,你拥有一个无限 ...

  7. Spring框架IOC和AOP的实现原理(概念)

    IoC(Inversion of Control) (1). IoC(Inversion of Control)是指容器控制程序对象之间的关系,而不是传统实现中,由程序代码直接操控.控制权由应用代码中 ...

  8. 使用js写简易的倒计时

    步骤 1.获取span标签2.获取现在的时间戳 3.获取未来的时间戳 4.将未来时间戳减去现在的时间戳等于相差的秒数 5.输出到页面 直接上代码 <span name="os" ...

  9. NetSec2019 20165327 Exp0 Kali安装 Week1

    NetSec2019 20165327 Exp0 Kali安装 Week1 一.下载并安装Kali和VMware kali在官网下载,VMware上学期已安装 安装如下步骤: 选典型: 选稍后安装操作 ...

  10. linux debug tools

    linux modules: IO schedule.VFS.OOM.memory.net.process schedule kernel debug: perf(IO bound\CPU bound ...