Untitled

unknown
plain_text
9 days ago
2.0 kB
14
Indexable
Never
```def is_prime(num):
x = 0

if num > 1:
for i in range(2, int((num * .5) + 1)):
if num % i == 0:
return f"{num} is not a prime number "

if num < -1:
return "please enter a + number"

if x == 0:
return f"the {num} is a prime number"

def is_pronic(num):
if 1 + (4 * num) < 0:
return "this is not a pronic number"

elif (1 + (4 * num)) ** .5 > int((1 + (4 * num)) ** .5):

return "this is not a pronic number"

if ((-1 + (1 + (4 * num)) ** .5)) / 2 == int(((-1 + (1 + (4 * num)) ** .5)) / 2):
printer = ((-1 + (1 + (4 * num)) ** .5)) / 2
return f"{num} is a pronic number and the 2 number is {int(printer)} , {int(printer + 1)}"

def show_maun():
while True:
print("[1] to show if the number is prime ".upper())
print("[2] to show if the number is pronic ".upper())
print("[3] to exit ".upper())

cho = input("Enter your choice : \n".upper())
while cho not in ['1', '2', '3']:
print("[1] to show if the number is prime ".upper())
print("[2] to show if the number is pronic ".upper())
print("[3] to exit ".upper())
cho = input("please enter a number between 1 to 3 : \n".upper())

if cho == '1':
num = input("Enter the number you want to know if it is prime or not : \n")
while num.isdigit() == False:
num = input("please enter a number : \n")
num = int(num)
print(is_prime(num))

elif cho == '2':
num = input("Enter the number you want to know if it is pronic or not : \n")
while num.isdigit() == False:
num = input("please enter a number : \n")
num = int(num)
print(is_pronic(num))

if cho == '3':
print("godbye!".upper())
exit()

show_maun()```