fork download
  1. def simplify(a, b):
  2. if a >= b:
  3. for i in range(1, (a + 1)):
  4. if (a % i == 0) & (b % i == 0):
  5. temp_a = a/i
  6. temp_b = b/i
  7. elif b > a:
  8. for i in range(1, (b + 1)):
  9. if (a % i == 0) & (b % i == 0):
  10. temp_a = a / i
  11. temp_b = b / i
  12. a = temp_a
  13. b = temp_b
  14. return a, b
  15. print(simplify(4, 8))
  16. print(simplify(1536, 78360))
  17. print(simplify(51478, 5536))
  18. print(simplify(46410, 119340))
  19. print(simplify(7673, 4729))
  20. print(simplify(4096, 1024))
Success #stdin #stdout 0.05s 9992KB
stdin
Standard input is empty
stdout
(1.0, 2.0)
(64.0, 3265.0)
(25739.0, 2768.0)
(7.0, 18.0)
(7673.0, 4729.0)
(4.0, 1.0)