def solution(target): primes = [i for i in range(2, target) if is_prime(i) == i] max_prime = 0 max_consecutive = 1 while max_consecutive < target - sum(primes[:max_consecutive]): max_consecutive += 1 index = 0 sum_prime = sum(primes[index:index + max_consecutive]) if is_prime(sum_prime) == sum_prime and sum_prime < target: max_prime = sum_prime else: while not (is_prime(sum_prime) == sum_prime) and sum_prime < target: index += 1 sum_prime = sum(primes[index:index + max_consecutive]) if is_prime(sum_prime) == sum_prime and sum_prime < target: max_prime = sum_prime return max_prime
def solution(): prime_possible = [i for i in range(1000, 10000) if is_prime(i) == i] count = 0 result = 0 for prime_1 in prime_possible: for prime_2 in prime_possible: prime_3 = 2 * prime_2 - prime_1 if prime_1 < prime_2 and is_permutation(str(prime_1), str(prime_2)) and is_permutation(str(prime_1), str(prime_3)) and prime_3 in prime_possible: count += 1 if count == 2: result = int(str(prime_1)+str(prime_2)+str(prime_3)) return result
def solution(limit): result = 1 for i in range(1, limit // 2): n = 2 * i d = 1 b = True while d * d <= n: if n % d == 0: if n % (d * d) == 0 and d != 1: b = False d = n if not (is_prime(d + n // d) == d + n // d): b = False d = n d += 1 if b: result += n return result
def solution(limit): count = 0 for number in range(2, limit): if is_prime(number) == number: count += number return count
def is_strong_right_truncable_Harshad(n): if not (is_prime(n) == n): return False else: return is_strong_harshad(int( str(n)[:-1])) and is_right_truncable_harshad(int(str(n)[:-1]))
def is_strong_harshad(n): if not (is_harshad(n)) or n == 1: return False else: return is_prime(n // sum([int(char) for char in str(n)])) == n // sum( [int(char) for char in str(n)])
def solution(): result = [] for i in range(1, 10000000): if is_pandigital(str(i)) and is_prime(i) == i: result.append(i) return result[-1]