Problem 5 Smallest multiple
来源:互联网 发布:申万宏源交易软件下载 编辑:程序博客网 时间:2024/06/05 04:52
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?
prime = [ 2,3,5,7,11,13,17,19]result = 1for i in prime:result *= ifor i in range(2,21):if result % i==0:continuetmp = ifor j in prime:if tmp % j == 0:tmp = tmp / jresult *= tmpprint result
def gcd(a,b): if b == 0:return a else:return gcd(b,a%b)def lcm(a,b): return ( a/gcd(a,b) )*br = 2for i in range(3,21): r = lcm(r,i)print r
阅读全文
0 0
- Problem 5:Smallest multiple
- Problem 5 Smallest multiple
- (Problem 5)Smallest multiple
- 【Project Euler】【Problem 5】Smallest multiple
- project euler problem 5:Smallest multiple
- Problem 5 Smallest multiple(LCM)
- Project Euler Problem 5: Smallest multiple
- projecteuler---->problem=5----Smallest multiple n个数求最小公倍数
- PE 5 Smallest multiple
- 5 Smallest multiple - Project Eulder
- Smallest multiple
- 欧拉计划(5) Smallest multiple
- Smallest Common Multiple
- Smallest Common Multiple
- Smallest Multiple by GoLang
- Smallest Common Multiple
- Project Euler 005 Smallest multiple
- Smallest multiple 求1-20的最小公倍数
- 关于单链表的基本操作
- 18通用属性
- Eclipse 格式化快捷键
- 最短路径spaf算法
- 19第一部分小结
- Problem 5 Smallest multiple
- ansysworkbench直线和曲线路径设置
- python queue
- codeforces 830B. Cards Sorting
- POJ 3135 Polygons on the Grid 笔记
- HDU 1029 Ignatius and the Princess IV (思路)
- 20header和footer
- I/O多路复用之epoll服务器
- php 正则验证手机和邮箱