project euler problem 131 https projecteuler netproblem131 there are some prime values p for which there exists a positive integer n such that the expression n3 n2p is a perfect cube for example when p 19 83 82 x 19 123 what is perhaps most surprising is that for each prime with this property the value of n is unique and there are only four such primes below onehundred how many primes below one million have this remarkable property determines whether number is prime isprime3 true isprime4 false returns number of primes below maxprime with the property solution100 4 determines whether number is prime is_prime 3 true is_prime 4 false returns number of primes below max_prime with the property solution 100 4
from math import isqrt


def is_prime(number: int) -> bool:
    

    return all(number % divisor != 0 for divisor in range(2, isqrt(number) + 1))


def solution(max_prime: int = 10**6) -> int:
    

    primes_count = 0
    cube_index = 1
    prime_candidate = 7
    while prime_candidate < max_prime:
        primes_count += is_prime(prime_candidate)

        cube_index += 1
        prime_candidate += 6 * cube_index

    return primes_count


if __name__ == "__main__":
    print(f"{solution() = }")