Project Euler 46 - Goldbach's other conjecture

Official link:

Thought Process

I made a function goldbachs(x) that takes a number, x, and checks if it can be written as a sum of a prime and twice a square.

I do this by creating a for loop going through y, from 1 to the sqrt(x), and I check if temp_var = x - 2y^2 is a prime, using my is_prime function, if it is then we can re-arrange like so, x = temp_var - 2y^2 and our condition is true so we return True, if we try all cases and none of them return True, we return False.

Then I just start a running count at 33, and start a while loop that will break if goldbachs(count) = False, then just keep increasing the count inside the while loop, also make sure you skip checking primes

Interactive Code

No interactive code for this one, code is given below