29 lines
465 B
Python
29 lines
465 B
Python
#!/usr/bin/python3
|
|
|
|
import pprint
|
|
|
|
from util.io import readvalue
|
|
|
|
|
|
def divisors(n):
|
|
return [i for i in range(2, n) if not n % i]
|
|
|
|
def is_prime(n):
|
|
return not divisors(n)
|
|
|
|
if( __name__ == "__main__"):
|
|
|
|
def positive_int(s):
|
|
v = int(s)
|
|
if(v > 0):
|
|
return v
|
|
|
|
number = readvalue("n > ", positive_int)
|
|
print("Divisors:")
|
|
pprint.pprint(divisors(number))
|
|
|
|
if(is_prime(number)):
|
|
print("Also", number, "is a prime.")
|
|
else:
|
|
print(number, "is not a prime.")
|