用Python解答 ProjectEuler问题(5)

E005
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 number that is evenly divisible by all of the numbers from 1 to 20?

能被1到20整除的数最小是多少?


from prime import Prime

def problem5():
    pri = Prime(20)
    #求pri.primes中所有元素的乘积
    def mul(x, y): return x*y
    max_power = reduce(mul, pri.primes, 1)
    return max_power


if __name__=='__main__':
    print str(problem5())


“能被1到20整除”也就是“能被1到20中的素数整除”,又一个与素数有关的问题

你可能感兴趣的:(python)