Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import fractions
  2.  
  3. x = int(input())
  4. y = int(input())
  5.  
  6. divider = x
  7. x = int(x / fractions.gcd(x, y))
  8. y = int(y / fractions.gcd(divider, y))
  9. stop = None
  10.  
  11. otherX = 1
  12. otherY = 1
  13.  
  14. while x != 1:
  15. stop = None
  16. while not stop:
  17. breuk = fractions.Fraction(x, y)
  18. breuk2 = fractions.Fraction(otherX, otherY)
  19. breuk3 = fractions.Fraction(otherX, otherY + 1)
  20. if breuk3 < breuk < breuk2:
  21. teller = x * (otherY + 1)
  22. noemer = y * (otherY + 1)
  23. andereTeller = y
  24. x = teller - andereTeller
  25. y = noemer
  26.  
  27. divider = x
  28. x = int(x / fractions.gcd(x, y))
  29. y = int(y / fractions.gcd(divider, y))
  30. stop = True
  31. print(otherY + 1)
  32. otherY += 1
  33. print(y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement