Project Euler 5

来源:互联网 发布:国内网络加速器 编辑:程序博客网 时间:2024/06/06 17:10
'''Created on 2014年8月26日Smallest multiple2520 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 = 20N = 1i = 1pVal =[2,3,5,7,11,13,17,19]limit = sqrt(k)check = Truefor 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)

0 0
原创粉丝点击