-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path047.py
executable file
·43 lines (31 loc) · 835 Bytes
/
047.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
#The first two consecutive numbers to have two distinct prime factors are:
#14 = 2 × 7
#15 = 3 × 5
#The first three consecutive numbers to have three distinct prime factors are:
#644 = 2² × 7 × 23
#645 = 3 × 5 × 43
#646 = 2 × 17 × 19.
#Find the first four consecutive integers to have four distinct primes factors. What is the first of these numbers?
#Answer:
#134043
from time import time; t=time()
T=S=4
M = 150000
faccnt = [0]*M
nrange = list(range(M))
for i in range(2, M):
if nrange[i] != 1:
for j in range(i, M, i):
nrange[j] = nrange[j//i]
faccnt[j] += 1
cnt = 0
for i in range(0, M-3):
if faccnt[i] == S:
cnt += 1
if cnt == T:
print(i-T+1)#, time()-t
break
else:
cnt = 0