-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem47.py
43 lines (39 loc) · 1.1 KB
/
problem47.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
def primeFactors(n):
i = 2
factors = []
count = 0 #added to test optimization
while i * i <= n:
count += 1 #added to test optimization
if n % i:
i += 1
else:
n //= i
factors.append(i)
if n > 1:
factors.append(n)
return factors
def distinctFactors(factors):
distinct = []
for factor in factors:
if factor not in distinct:
distinct.append(factor)
return len(distinct)
consec = 4
num = 10
finished = False
while not finished:
num += 1
factors = [[] for x in range(consec)]
finished = True
for j in range(consec):
factors[j] = primeFactors(num+j)
if len(factors[j]) < consec:
finished = False
# count distinct prime factors used in case
if finished:
for i in range(len(factors)):
if distinctFactors(factors[i]) < consec:
finished = False
print(num)
for i in range(consec):
print(primeFactors(num + i))