Project Euler 291 - Panaitopol Primes

Official link: https://projecteuler.net/problem=291

Note: My code takes around ~670s

Thought Process

Brute forcing the first few values leads you to https://oeis.org/A027862, which are primes of the form n^2 + (n+1)^2.

Using this I used my Fermat primality test and just brute forced the answer, took around 11 mins but oh well, even most of the top solvers brute forced it. I tried to implement the Miller-Rabin Primality Test but it turned out to be slower, nevertheless I have added it to my math library

But of course all of this hinges on the fact that all Panaitopol Primes are indeed primes of the form n^2 + (n + 1)^2, below I illustrate a proof.

Interactive Code

Enter a number (yourinput)

Code will output the number of Panaitopol primes less than yourinput