project_euler.problem_111.sol1¶
Project Euler Problem 111: https://projecteuler.net/problem=111
Primes with Runs
First, note that for sequence of 10 digits, M(4,d) is 8 or 9. Start by constructing prime list up to sqrt(n), which are used to check if number is prime. Then iterate over possible combinations of numbers checking each if prime.
Functions¶
Calculates the list of primes up to and including n. |
|
|
Check in int n is prime using primes_all list of relatively small primes |
|
Check each possible combination if it is prime. |
Module Contents¶
- project_euler.problem_111.sol1.generate_primes(n: int)¶
Calculates the list of primes up to and including n.
>>> generate_primes(6) [2, 3, 5]
- project_euler.problem_111.sol1.is_prime(n, primes_all)¶
Check in int n is prime using primes_all list of relatively small primes compared to n.
>>> is_prime(5, [2, 3]) True
- project_euler.problem_111.sol1.solution(n: int = 10000000000) int¶
Check each possible combination if it is prime.
>>> solution(10000) 273700