Getting a runtime error. Please resolve
Prateek loves candy error
the logic of your code of finding prime is not correct…moreover we do not have to print prime or not prime…see the sample output once again…
approach this ques using seive of eratosthenes and pre compute the answer so as to optimize your code
Can you point out the logical issue in my solution please ? Also, I am printing “Prime”/“Not Prime”. Please check again and revert back.
Yeah I agree that it will reduce the time complexity in my case but I need to know where is the mistake in this solution too. Thanks !
do a dry run for this input
1
5
in the else condition your code will go…the inner for loop will never execute…thus counter will never change so the outer for loop becomes an infinite loop
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.