def prime(n):
if n<=1:
return None
for i in range(2,n+1):
if n%i==0:
print(“Not Prime”)
else:
print(“Prime”)
n=int(input())
prime(n)
Why not run this code sir?
Hi as you mentioned in your code, if the “else” statement is inside the for loop, then for every value of i in which n%i!=0, your code will print “Prime”. So that’s why we will not be using this.
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.