Just use the function name itself - in this case, R
- and call it the same way you call it from the outside.
For other algorithms that can be calculated with recursion, as a factorial, it is easier to understand:
def factorial(n):
if n == 1:
return 1
return n * factorial(n - 1)
With the notation used, and since I do not know the function, I can not understand what you want to calculate with your function to be able to rewrite it recursively.
As it is written there, you call R
recursively with the value (1/x+2/x)
but x
and a global variable set outside the function - so except in a single special case, x
will never be equal to 1, and its function will never reach the stop value - the function will only terminate the recursion, and start returning the values when it is called with the value "1".
And even if you change "x" to "n" in the call to R in line return 1/1/x-1/R(1/x+2/x)*n/1*n
, I do not think the expression "1 / x + 2 / x" converges to "1" - this just happens with the value "3" in x - so I think you need to explain better the formula you want to calculate recursively if you want more help than that.