Advertisement
Bad_Programist

Untitled

Nov 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def NOD(a, b):
  2.     while b != 0:
  3.         a, b = b, a % b
  4.     return a
  5.  
  6. def ReduceFraction(m, n):
  7.     if NOD(m, n) != 1:
  8.         N = NOD(m, n)
  9.         m //= N
  10.         n //= N
  11.     return [m, n]
  12. a = int(input())
  13. b = int(input())
  14. S = ReduceFraction(a, b)
  15. print(S[0], S[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement