本题来自 Project Euler 第6题:https://projecteuler.net/problem=6

# Project Euler: Problem 6: Sum square difference
# The sum of the squares of the first ten natural numbers is,
# 1**2 + 2**2 + ... + 10**2 = 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.
# Answer: 25164150 x = y = 0
for i in range(1, 101):
x += i
y += i**2
print(x**2 - y)

这题纯粹是送分题,就是简单的加减法和乘方计算。应该没啥算法可言吧。。。

Python练习题 034:Project Euler 006:和平方与平方和之差的更多相关文章

  1. Python练习题 032:Project Euler 004:最大的回文积

    本题来自 Project Euler 第4题:https://projecteuler.net/problem=4 # Project Euler: Problem 4: Largest palind ...

  2. Python练习题 029:Project Euler 001:3和5的倍数

    开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we ...

  3. Python练习题 046:Project Euler 019:每月1日是星期天

    本题来自 Project Euler 第19题:https://projecteuler.net/problem=19 ''' How many Sundays fell on the first o ...

  4. Python练习题 039:Project Euler 011:网格中4个数字的最大乘积

    本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest pro ...

  5. Python练习题 033:Project Euler 005:最小公倍数

    本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multi ...

  6. Python练习题 049:Project Euler 022:姓名分值

    本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names sco ...

  7. Python练习题 048:Project Euler 021:10000以内所有亲和数之和

    本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable ...

  8. Python练习题 047:Project Euler 020:阶乘结果各数字之和

    本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial ...

  9. Python练习题 045:Project Euler 017:数字英文表达的字符数累加

    本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter coun ...

随机推荐

  1. [PyTorch 学习笔记] 3.2 卷积层

    本章代码:https://github.com/zhangxiann/PyTorch_Practice/blob/master/lesson3/nn_layers_convolution.py 这篇文 ...

  2. 拿捏了!ConcurrentHashMap!

    概述 本文将对JDK8中 ConcurrentHashMap 源码进行一定程度的解读.解读主要分为六个部分:主要属性与相关内部类介绍.构造函数.put过程.扩容过程.size过程.get过程.与JDK ...

  3. 理解Django 中Call Stack 机制的小Demo

    1.工作流程 request/response模式下,request并不是直接到达view方法,view方法也不是将返回的response直接发送给浏览器的,而是request由外到里的层层通过各种m ...

  4. 前端模块化IIFE,commonjs,AMD,UMD,ES6 Module规范超详细讲解

    目录 为什么前端需要模块化 什么是模块 是什么IIFE 举个栗子 模块化标准 Commonjs 特征 IIFE中的例子用commonjs实现 AMD和RequireJS 如何定义一个模块 如何在入口文 ...

  5. php利用快递100接口获取物流信息

    PHP使用CURL调用快递100接口查询运单信息 类代码如下: <?php/** * 快递100接口调用类 * @author 齐云海 * date: 2019/05/29 */ class E ...

  6. Java-学习日记(100 == 100为true,1000 == 1000却为false?)

    Integer底层设计 100 == 100为true,1000 == 1000却为false? 之前也写过String的==与equals的注意点,这次写下Integer的底层设计,不妨先运行下下面 ...

  7. Fitness - 05.23

    倒计时222天 运动40分钟,共计8组,4.2公里.拉伸10分钟. 每组跑步3分钟(6.5KM/h),走路2分钟(5.5KM/h). 终于赶在姨妈前完成第3周的跑步训练了,可喜可贺~~ 下周预计要休息 ...

  8. Unity透明地形

    http://answers.unity3d.com/questions/1162779/unity-5-transparent-terrain-shader.html http://answers. ...

  9. 1090 Highest Price in Supply Chain (25 分)(模拟建树,找树的深度)牛客网过,pat没过

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  10. chrome设置跨域访问

    1.新建目录 /usr/local/opt/myChromData 2.输入命令行 open -n /Applications/Google\ Chrome.app/ --args --disable ...