fork download
  1. def recurse(x, y, ans):
  2. if x == y:
  3. ans += 1
  4. elif x > y:
  5. if y == 1:
  6. ans += x
  7. else:
  8. ans += 1
  9. x = x-y
  10. recurse(x, y, ans)
  11. elif x < y:
  12. if x == 1:
  13. ans += y
  14. else:
  15. ans += 1
  16. y = y-x
  17. recurse(x, y, ans)
  18. return ans
  19.  
  20. p = int(input())
  21. q = int(input())
  22. r = int(input())
  23. s = int(input())
  24. ans = 0
  25. a = 0
  26. for i in range(p, q+1):
  27. for j in range(r, s+1):
  28. x = max(i,j)
  29. y = min(i,j)
  30. a += recurse(x, y)
  31. print(a)
  32.  
Runtime error #stdin #stdout #stderr 0.12s 23700KB
stdin
1
1500
1
1500
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 30, in <module>
TypeError: recurse() missing 1 required positional argument: 'ans'