You are currently viewing a revision titled "prime number program code", saved on May 26, 2013 at 1:23 pm by Anne Menmou | |
---|---|
Title | prime number program code |
Content | # check weather a number is prime or not
# A prime number is a number that have only two divider: 1 and itself.
p=int(input("Enter an integer: "))
if p in [0, 1, 4, 6]:
print(p, "is not a prime number!")
elif p in [2, 3, 5]:
print(p, "is a prime number!")
else:
p1=p+1
p2=p-1
remainder1=p1%6
remainder2=p2%6
if remainder1==0 or remainder2==0:
print(p, "is a prime number!")
else:
print(p, "is not a prime number!") |
Excerpt | |
Footnotes |