Sort 32 Discussions, By:
Please Login in order to post a 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).
In the problem statement,for a=-1,b=41 is it 41 primes or 42 primes?
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) :)
Why am I getting wrong answer in test case 4? Others are working fine.
Tip: b must be prime (consider n = 0). a can be similarly restrained (consider n = 1).