fork download
  1. import math
  2. a, b = map(int, input().split())
  3. d = math.gcd(a, b)
  4. uoc = set()
  5. for i in range(1, int(math.sqrt(d)) + 1):
  6. if d%i == 0:
  7. uoc.add(i)
  8. uoc.add(d//i)
  9. dd = list(uoc)
  10. dd.sort(reverse = True)
  11. print(dd[1])
Success #stdin #stdout 0.07s 14148KB
stdin
30 40
stdout
5