Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 22 lines (16 sloc) 581 Bytes
#!/usr/bin/env python
import argparse
from math import sqrt
from itertools import count, islice
# Python program to check if the input number is prime or not
def is_prime(n):
return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("number", help="display whether a number is prime or not",
args = parser.parse_args()
if is_prime(args.number):
print('The number: {} is prime'.format(args.number))
print('The number: {} is not prime'.format(args.number))