A recursion depth error says you have too many functions calling functions calling functions and so on and so on and Python has decided that is enough. I think the limit is 1000 functions deep. Usually this happens because your recursive function has a bug, but it could just be that you need more recursive function calls than Python allows.
The reason you are exceeding the max recursive calls limit is because your code is wrong. I will simplify.
def gcd(x,y):
gcd_helper(x, y, y)
def gcd_helper(x, y, f):
gcd(x,y)
See it now? Without changing the value of x or y, gcd calls gcd_helper(x, y, -), The first thing gcd_helper does is call gcd(x, y). This goes on about 500 times and your program crashes.
I do not know what the logic should be, but somewhere there has to be something that returns a value without having to make a function call. Your code doesn't have that.
Larz is correct about lines 6 and 7 being unreachable, but it doesn't make any difference because the results would be the same even if the function did include them in the execution path.
def gcd(x,y):
if x > y:
return gcd_helper(x, y, y)
if x == y:
return gcd_helper(x, y ,x)
return gcd_helper(x, y, x)
Here we have different logic for x == y and x < y, but it does the same thing as this
def gcd(x,y):
if x > y:
return gcd_helper(x, y, y)
return gcd_helper(x, y, x)
Since the code is all wrong it probably doesn't matter.