Accept a number x as input.
• - if x is a prime number, print "prime"
. - if x is not a prime number, then print "odd" if x is an odd number
. - if x is not a prime number, then print "even" if x is an even number
1
Answers
Answered by
0
def is_prime(n):
for i in range(2, n):
if n % i == 0:
return 0
return 1
def is_even_odd(n):
if n % 2 == 0:
return "even"
return "odd"
if __name__ == "__main__":
while True:
n = int(input("num: "))
if n < 2:
print("enter an int > 1")
continue
else:
if is_prime(n):
print("prime")
else:
print(is_even_odd(n))
break
Similar questions