Skip to content

Instantly share code, notes, and snippets.

@adityasuseno
Created July 14, 2019 21:35
Show Gist options
  • Save adityasuseno/faab296dff91a4f6a77316fc8ac7dcb0 to your computer and use it in GitHub Desktop.
Save adityasuseno/faab296dff91a4f6a77316fc8ac7dcb0 to your computer and use it in GitHub Desktop.
Simple program to check whether a given number is prime or not
#!/usr/bin/env python3
#Simple program to check whether a number is prime or not
def isPrime(n):
if n < 2:
return False
elif n == 2:
return True
else:
for i in range(2, n):
p = n % i
if p == 0:
return False
break
return True
while True:
try:
r = int(input('input Number: '))
break
except ValueError:
print('Please Enter Number Only!')
print(isPrime(r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment