project_euler.problem_187.sol1¶
Project Euler Problem 187: https://projecteuler.net/problem=187
A composite is a number containing at least two prime factors. For example, 15 = 3 x 5; 9 = 3 x 3; 12 = 2 x 2 x 3.
There are ten composites below thirty containing precisely two, not necessarily distinct, prime factors: 4, 6, 9, 10, 14, 15, 21, 22, 25, 26.
How many composite integers, n < 10^8, have precisely two, not necessarily distinct, prime factors?
Functions¶
|
Benchmarks |
|
Returns prime numbers below max_number. |
|
Returns prime numbers below max_number. |
|
Returns the number of composite integers below max_number have precisely two, |
|
Returns the number of composite integers below max_number have precisely two, |
|
Returns the number of composite integers below max_number have precisely two, |
Module Contents¶
- project_euler.problem_187.sol1.benchmark() None ¶
Benchmarks
- project_euler.problem_187.sol1.calculate_prime_numbers(max_number: int) list[int] ¶
Returns prime numbers below max_number. See: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
>>> calculate_prime_numbers(10) [2, 3, 5, 7]
>>> calculate_prime_numbers(2) []
- project_euler.problem_187.sol1.slow_calculate_prime_numbers(max_number: int) list[int] ¶
Returns prime numbers below max_number. See: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
>>> slow_calculate_prime_numbers(10) [2, 3, 5, 7]
>>> slow_calculate_prime_numbers(2) []
- project_euler.problem_187.sol1.slow_solution(max_number: int = 10**8) int ¶
Returns the number of composite integers below max_number have precisely two, not necessarily distinct, prime factors.
>>> slow_solution(30) 10
- project_euler.problem_187.sol1.solution(max_number: int = 10**8) int ¶
Returns the number of composite integers below max_number have precisely two, not necessarily distinct, prime factors.
>>> solution(30) 10
- project_euler.problem_187.sol1.while_solution(max_number: int = 10**8) int ¶
Returns the number of composite integers below max_number have precisely two, not necessarily distinct, prime factors.
>>> while_solution(30) 10