We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# Project Euler #27: Quadratic primes

# Project Euler #27: Quadratic primes

+ 1 comment Problem statements are so confusing. Let me clear the air so that others wont need to waste their time in figuring out the ask like i did.

For the given input N, you have to find two cofficients a and b for the given equation such that, |a| <= N and |b| <= N so that you can find maximum number of primes. e.g

For input : 42 answer is : a = -1 and b = 41 because |a| <= 42 and and |b| <= 42

Note that 42 is not the total number of primes because total number of primes will 41 (0-40).

+ 1 comment In the problem statement,for a=-1,b=41 is it 41 primes or 42 primes?

+ 1 comment I put this here to help others :

`- As you may know you have to loop for each a and b (in some range) - For n = 0 the equation produces a prime number iff b is prime. - For n = 1, the equation produces a prime iff a is odd (otherwise the result is even ==> not prime) :)`

+ 3 comments Why am I getting wrong answer in test case 4? Others are working fine.

+ 0 comments Tip: b must be prime (consider n = 0). a can be similarly restrained (consider n = 1).

Load more conversations

Sort 32 Discussions, By:

Please Login in order to post a comment