I could not understand why n-1 is taken in the loop.
In bool is prime , above
hello @swaraj
a number n is said to be prime , if n is not divisible by any of the number in ranger from i=2 to i=n-1 .
that is why in loop we iterating from i=2 to i=n-1
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.