test case failed its saying time limit exceeded but when i m doing it on other ide it is running perfectly. Can you tell me where i am doing it wrong ?
plz see once my code and help me out…
https://ide.codingblocks.com/s/37694
Prateek loves candy (fundamental challenger) - time Exceed
Actually there is no problem with your code. But it needs more optimization.
Checking prime for each number would take more time and is thus very inefficient.
That’s why your code gives TLE on submitting as your code might run for smaller inputs, but it fails for larger inputs. TLE(time limit exceeded) error is due to inefficency of your code.
You can learn more about this error from here
This question can be solved very efficiently using the Sieve of Eratosthenes.
It would increase the efficiency of program.
Is there any video on Sieve of Eratosthenes. i dont know anything about this concept
I’m not sure about the video content, but you can easily find and study about it from internet. It is a pretty simple and easy algorithm.
The online course has a video on that under the Topic : NUMBER THEORY BASICS