It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.
It turns out that the conjecture was false.
What is the smallest odd composite that cannot be written as the sum of a prime and twice a square?
In [1]:
N = 10000
sieve = [False, False] + [True]*N
for p in range(N):
if sieve[p]:
for m in range(p*p, N, p):
sieve[m] = False
for n in range(9, N, 2):
if sieve[n]:
continue
delta = 6
m = n - 2
while m > 2 and not sieve[m]:
m -= delta
delta += 4
if m <= 2:
print(n)
break
In [ ]: