Advertisement
JHDsBR

MMC.py

Feb 20th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #MMC
  2. #Não garanto  ser 100% exato
  3.  
  4.  
  5. num1 = int(input("Numerador: "))
  6. num2 = int(input("Denominador: "))
  7.  
  8. menor = num2
  9.  
  10. if num1 <= num2:
  11.     menor = num1
  12.  
  13. cont = 1
  14. mmc = 1
  15. while True:
  16.  
  17.     if cont == menor:
  18.         break
  19.  
  20.     cont += 1
  21.    
  22.     if num1 % cont == 0 and num2 % cont == 0:
  23.  
  24.         num1 /= cont
  25.         num2 /= cont
  26.        
  27.         menor = num2
  28.         if num1 <= num2:
  29.             menor = num1
  30.  
  31.         mmc *= cont
  32.        
  33.         cont = 1
  34.  
  35. if mmc != 1:
  36.     print()
  37.     print("%.0f"%num1)
  38.     print("---")
  39.     print("%.0f"%num2)
  40.     print("MMC:",mmc)
  41. else:
  42.     print("Não tem")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement