project_euler.problem_047.sol1¶
Combinatoric selections
Problem 47
The first two consecutive numbers to have two distinct prime factors are:
14 = 2 x 7 15 = 3 x 5
The first three consecutive numbers to have three distinct prime factors are:
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. What is the first of these numbers?
Functions¶
|
Check the equality of ALL elements in an iterable |
|
Runs core process to find problem solution. |
|
Return the first value of the first four consecutive integers to have four |
|
Find unique prime factors of an integer. |
|
Memoize upf() length results for a given value. |
Module Contents¶
- project_euler.problem_047.sol1.equality(iterable: list) bool ¶
Check the equality of ALL elements in an iterable >>> equality([1, 2, 3, 4]) False >>> equality([2, 2, 2, 2]) True >>> equality([1, 2, 3, 2, 1]) False
- project_euler.problem_047.sol1.run(n: int) list[int] ¶
Runs core process to find problem solution. >>> run(3) [644, 645, 646]
- project_euler.problem_047.sol1.solution(n: int = 4) int | None ¶
Return the first value of the first four consecutive integers to have four distinct prime factors each. >>> solution() 134043
- project_euler.problem_047.sol1.unique_prime_factors(n: int) set ¶
Find unique prime factors of an integer. Tests include sorting because only the set matters, not the order in which it is produced. >>> sorted(set(unique_prime_factors(14))) [2, 7] >>> sorted(set(unique_prime_factors(644))) [2, 7, 23] >>> sorted(set(unique_prime_factors(646))) [2, 17, 19]
- project_euler.problem_047.sol1.upf_len(num: int) int ¶
Memoize upf() length results for a given value. >>> upf_len(14) 2