Why is the second if written outside the loop brackets?
Doubt about the condition for prime
Hello @sirprashar ,
If it was placed inside the loop, then the condition i==n would never be satisfied inside the loop as the loop is running for i<=n-1.
So, as soon as the loop terminates, we need to check whether the loop was completely executed (1==n, in case of a prime number) or was it terminated for a value less than n (i<n, in case of a non-prime number).
Hit like if you understood.