Facing problem with my code for POTATOES

Solution: 42156058 | CodeChef.
This is my submission for POTATOES problem. Please help.

Difference between consecutive primes, can be more 10, so you should not check the answer just till n+10.

I would indeed increase my knowledge before attending the problem. Here’s the Link where good information about Primes and differences between primes is given.

This should be noted.

However, prime gaps of n numbers can occur at numbers much smaller than n!. For instance, the first prime gap of size larger than 14 occurs between the primes 523 and 541, while 15! is the vastly larger number 1307674368000.

I would recommend you to use Sieve Of Eratosthenes to solve the problem. Of course, you’ll have to modify it a bit. Happy Coding :grin: