Project Euler 27 - Quadratic primes
Project Euler 27 - Quadratic primes
Official link: https://projecteuler.net/problem=27
Thought Process
Thought Process
Notice a few things about f(n) = n^2 + an + b with respect to finding primes
f(0) = b
This tells us that b must be a prime between 1 and 1000, I used my prime generation function for this
f(1) = 1 + a + b
for f(1) to be a prime f(1) >= 2 => 1 + a + b >= 2 => a >= 1 - b
This means we only have to check values of a between 1-b and 1000
I created a simple function which takes inputs a, b and find the number of primes in a row n^2 + an + b generates. I used my is_prime function for this
Interactive Code
Interactive Code
Input an integer (yourinput)
Code will output a*b such that n^2 + an + b create the most number of consecutive primes and a, b <= |yourinput|