-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmallmult.py
More file actions
46 lines (45 loc) · 912 Bytes
/
Copy pathsmallmult.py
File metadata and controls
46 lines (45 loc) · 912 Bytes
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
#s = 20
#stop = False
#while(not stop):
# divs = (19,18,17,16,15,14,12,11,9,8,7,6,3)
## print(s)
# for d in divs:
# if(s % d != 0):
# break
# if(d == 20):
# stop = True
# break
# s += 20
#print("Solution found")
#print(s)
import math as m
def prime_factors(n):
factors = []
d = 2
while n > 1:
while n % d == 0:
factors.append(d)
n /= d
d = d + 1
if d*d > n:
if n > 1:
factors.append(n)
break
return factors
#factorization
d_fac = []
for d in range(2,21):
d_fac.append(prime_factors(d))
#counting
maxs = [0]*20
for r in d_fac:
for i in set(r):
comp = r.count(i)
if comp > maxs[i-1]:
maxs[i-1] = comp
#compiling
res = 1
for x in range(1,21):
if(maxs[x-1] > 0):
res *= m.pow(x,maxs[x-1])
print(res)