the smallest positive number
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
程序比较好编,就是考验计算机。最大范围也是预估的,边写边调。
尽管算对了,但方式可能不对。
def div2(n,x): isDiv = True for i in xrange(2,n): if x % i != 0 : isDiv = False break return isDiv for i in xrange(2,1772146456): if div2(21,i) == True: print i break
输出:
C:\webpy\webpy\Scripts\python.exe C:/pycode/euler.py
232792560
Process finished with exit code 0
后来请高手重新写了一个,这个就很正规了。
def getSmallestNum(m,n): for j in range(1,n): if( m*j%n ==0 ): return m*j return m*n smallestNum = 1 for i in range(2,21): if(smallestNum%i !=0): smallestNum = getSmallestNum(smallestNum,i) print smallestNum
the smallest positive number的更多相关文章
- 为什么实数系里不存在最小正数?(Why the smallest positive real number doesn't exist in the real number system ?)
We define the smallest positive real number as the number which is explicitly greater than zero and ...
- projecteuler Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- (Problem 5)Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Problem 5: Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Project Euler欧拉计划
1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. Th ...
- a questions
1.2520 is the smallest nuber that can be diveded by each of the number from 1 to 10 without any rema ...
- 欧拉计划 NO05 ps:4题想过,好做,但麻烦,有时间补充,这题也不难!
问题重述: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without an ...
- Problem5-Project Euler
Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to ...
- Project Euler Problem5
Smallest multiple Problem 5 2520 is the smallest number that can be divided by each of the numbers f ...
随机推荐
- Demo_敌军坦克生成,坦克移动(可以拓展发射子弹,敌军消失获取分数或者添加动画,声音功能)
using UnityEngine; using System.Collections; public class Tank : MonoBehaviour { //坦克面积结构体对象 public ...
- 【甘道夫】怎样在cdh5.2上执行mahout的itemcf on hadoop
环境: hadoop-2.5.0-cdh5.2.0 mahout-0.9-cdh5.2.0 步骤: 基本思路是,将mahout下的全部jar包都引入hadoop的classpath就可以,所以改动了$ ...
- 高性能 Socket 组件 HP-Socket v3.2.1-RC5 公布
HP-Socket 是一套通用的高性能 TCP/UDP Socket 组件,包括服务端组件.client组件和 Agent 组件,广泛适用于各种不同应用场景的 TCP/UDP 通信系统,提供 C/C+ ...
- linux定时任务1-crontab命令
简单测试例子: 添加定时任务前,注意查看crond服务是否已经启动,如果未启动,则用命令service crond start命令启动. 注意给脚本添加可执行权限. [root@rheltest1 ~ ...
- 转 - markdown 简明语法
Markdown是一种极简的『标记语言』,将文本转为HTML,通常为我大码农所用.其不追求大而全,简洁至上,正所谓不求最贵,只求最好! 本文介绍Markdown基本语法,内容很少,一行语法一行示例,学 ...
- SuperSocket快速入门(一):什么是SuperSocket
什么是SuperSocket SuperSocket(下文简称SS)是一个轻量级, 跨平台而且可扩展的 .Net/Mono Socket 服务器程序框架.你无须了解如何使用 Socket, 如何维护 ...
- SQL 去除小数点后无效 0 的方法
select convert(float,10.0000) 就是这么简单
- boostrap按钮
bootstrap按钮 对应链接:http://v3.bootcss.com/css/#buttons 使用时添加基础类class:btn 默认样式class=btn-default,控制大小clas ...
- javascript基础之变量和函数声明
1.变量的声名 window.name = 'gjlin' ; //全局变量 直接name = 'gjlin' 也表示全局变量,但是建议使用window.name = 'gjlin' 这种形式表示 ...
- MySQL性能调优与架构设计读书笔记
可扩展性设计之数据切分 14.2 数据的垂直切分 如何切分,切分到什么样的程度,是一个比较考验人的难题.只能在实际的应用场景中通过平衡各方面的成本和利益,才能分析出一个真正适合自己的拆分方案. 14. ...