Not correct output

code link:https://ide.codingblocks.com/s/89174

Hi @Rohan_singla,you have not reinitialized flag=true after while loop.

hlo @cutiecoder
still same problem persists

see you have to terminate your for loop till i<l but you have done it i<=l and next when l==0 or l==1 then count should not be incremented as 0,1 are not prime numbers.
I have the required changes to your code you can see it:


and try to seive method in this question if your code will give tle on subission.

hlo @cutiecoder
now this code is giving 2 correct test cases but in 1 test case time limit exceed, what to do then?

try using seive method to check whether the number is prime or not.