Advertisement
yiwen_akeni

program to find max prim of a two numbers number

Oct 24th, 2022
1,669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | Source Code | 0 0
  1. # program to find max prim of a two numbers
  2. x = int(input("write your 1st number : "))
  3. if x == 0:
  4.     print ("1st number equal to zero no prim number is possible")
  5.     exit()
  6. y = int(input("write your 2nd number : "))
  7. if y == 0:
  8.     print ("2nd number equal to zero no prim number is possible")
  9.     exit()
  10. if x == y:
  11.     print ("same number given")
  12.     i = x - 1
  13.     while i > 0:
  14.         if x % i == 0:
  15.             print("max prim is : " + str(i))
  16.             break
  17.         else:
  18.             i -= 1
  19. else:
  20.     if x > y:
  21.         i = y
  22.     else :
  23.         i = x
  24.     while i > 0:
  25.         if x % i == 0 and y % i == 0:
  26.             print("max prim is : " + str(i))
  27.             break
  28.         else:
  29.             i -= 1
Tags: math pyhton3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement