failing testcase plz resolve
Https://ide.codingblocks.com/s/122875
hi @Tusharbhatia15,
That is because the algorithm you have used checks for each value in between a and b.There is a method to find primes and then store it in a boolean array. Method is known as Sieve of Eratosthenes.This method will reduce time taken .In the method make a boolean array of b+1 size and make all the fields as true and then run from 2 till sqrt(n) and if value at index i is true then do all the further multiple of i as false. Now use a second loop from a to search number of true in the array . This will give you your count in less time.Try to code this method
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.