'''
Created on 2014年8月26日
Smallest multiple
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?
@author: wxp2971
'''
# 从解答中伪代码中编写的,开始的思路是自己手工化简的,人工确定需要那些项,质数的概念
from numpy import *
k = 20
N = 1
i = 1
pVal =[2,3,5,7,11,13,17,19]
limit = sqrt(k)
check = True
for i in range(len(pVal)):
tempVal = 1
if check:
if pVal[i] <= limit:
tempVal = floor(log(k) /log(pVal[i]))
else:
check = False
N = N *(power(pVal[i],int(tempVal)))
print(N)
Project Euler 5
最新推荐文章于 2020-07-28 10:06:10 发布