-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler-005.py
47 lines (40 loc) · 912 Bytes
/
euler-005.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on Sun May 14 01:17:34 2017
@author: Steven
"""
from functools import reduce
import time
tStart = time.time()
def gcd(a,b):
"""Return greatest common divisor"""
while b:
a, b = b, a % b
return a
def lcm(a, b):
"""Return lowest common multiple"""
return a * b // gcd(a, b)
def lcmm(*args):
"""Return lcm of args."""
return reduce(lcm, args)
for i in range(20,200):
tStart = time.time()
print(lcmm(*range(1, i)))
print(i, " run time = " + str((time.time() - tStart)))
tStart = time.time()
def delbart(t,n):
if n > 0:
if not (t%n):
if delbart(t, n-1):
return True
else:
return False
else:
return False
else:
return True
i = 20
while not delbart(i,20):
i +=20
print (i)
print("run time = " + str((time.time() - tStart)))