Adopted new convention from template
This commit is contained in:
parent
60d89e8681
commit
6fd86f8cde
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 12 Sep 2021
|
Created on 12 Sep 2021
|
||||||
|
|
||||||
@ -11,6 +11,7 @@ https://projecteuler.net/problem=47
|
|||||||
|
|
||||||
from utils import timeit
|
from utils import timeit
|
||||||
|
|
||||||
|
|
||||||
def factor(n):
|
def factor(n):
|
||||||
ans = []
|
ans = []
|
||||||
d = 2
|
d = 2
|
||||||
@ -22,27 +23,32 @@ def factor(n):
|
|||||||
d += 1
|
d += 1
|
||||||
if n > 1:
|
if n > 1:
|
||||||
ans.append(n)
|
ans.append(n)
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
@timeit("Problem 47")
|
@timeit("Problem 47")
|
||||||
def compute():
|
def compute():
|
||||||
"""
|
"""
|
||||||
The first two consecutive numbers to have two distinct prime factors are:
|
The first two consecutive numbers to have two distinct prime factors are:
|
||||||
|
|
||||||
14 = 2 × 7
|
14 = 2 x 7
|
||||||
15 = 3 × 5
|
15 = 3 x 5
|
||||||
|
|
||||||
The first three consecutive numbers to have three distinct prime factors are:
|
The first three consecutive numbers to have three distinct prime factors
|
||||||
|
are:
|
||||||
|
|
||||||
644 = 2² × 7 × 23
|
644 = 2² x 7 x 23
|
||||||
645 = 3 × 5 × 43
|
645 = 3 x 5 x 43
|
||||||
646 = 2 × 17 × 19.
|
646 = 2 x 17 x 19.
|
||||||
|
|
||||||
|
Find the first four consecutive integers to have four distinct prime
|
||||||
|
factors each.
|
||||||
|
|
||||||
Find the first four consecutive integers to have four distinct prime factors each.
|
|
||||||
What is the first of these numbers?
|
What is the first of these numbers?
|
||||||
"""
|
"""
|
||||||
ans = []
|
|
||||||
|
|
||||||
|
ans = []
|
||||||
for number in range(1, 1_000_000):
|
for number in range(1, 1_000_000):
|
||||||
if len(ans) == 4:
|
if len(ans) == 4:
|
||||||
break
|
break
|
||||||
@ -54,7 +60,5 @@ def compute():
|
|||||||
return ans[0]
|
return ans[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 47 is {compute()}")
|
||||||
print(f"Result for Problem 47: {compute()}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user