My code is working fine on my system and the codingblocks ide for the given sample inputs, but it is showing timelimit error when I submit the problem
https://ide.codingblocks.com/s/54535
Timelimit error in Prateek Loves Candy problem
Hi Ishita, according to your code, for every test case you’ll check every number whether it’s prime or not. This would increase the complexity. To improve the complexity of this code, use Sieve of Eratosthenes.
You can read more about it here https://www.geeksforgeeks.org/sieve-of-eratosthenes/.