diff --git a/src/Python/Problems001-050/Problem047.py b/src/Python/Problems001-050/Problem047.py index 342abdb..fb4faee 100644 --- a/src/Python/Problems001-050/Problem047.py +++ b/src/Python/Problems001-050/Problem047.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 12 Sep 2021 @@ -11,6 +11,7 @@ https://projecteuler.net/problem=47 from utils import timeit + def factor(n): ans = [] d = 2 @@ -22,27 +23,32 @@ def factor(n): d += 1 if n > 1: ans.append(n) + return ans + @timeit("Problem 47") def compute(): """ The first two consecutive numbers to have two distinct prime factors are: - 14 = 2 × 7 - 15 = 3 × 5 + 14 = 2 x 7 + 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 - 645 = 3 × 5 × 43 - 646 = 2 × 17 × 19. + 644 = 2² x 7 x 23 + 645 = 3 x 5 x 43 + 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? """ - ans = [] + ans = [] for number in range(1, 1_000_000): if len(ans) == 4: break @@ -52,9 +58,7 @@ def compute(): ans = [] return ans[0] - if __name__ == "__main__": - - print(f"Result for Problem 47: {compute()}") \ No newline at end of file + print(f"Result for Problem 47 is {compute()}")