Project Euler 27 - Quadratic primes

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

Thought Process

Notice a few things about f(n) = n^2 + an + b with respect to finding primes

  1. f(0) = b

  2. 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

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|