The problem is given a recursive function in python (or similar), can it be re-written it so that it doesn't reference itself. I've made a simple example which applies to the problem. Of course, making it a non-recursive function is not allowed. It must still do the same recursion process.

def fact(n): if n == 0: return 1 return n * fact(n - 1)

It's also equivalent to a short-hand.

fact = lambda n: 1 if n == 0 else n * fact(n - 1)

In the example, I shouldn't call fact inside the function definition.

Edit:

Additional constraints: Assignments must not be necessary for the solution to work.

One solution (from the comments) without the additional constraint is to create two functions a and b which call each other alternately and do factorial effevtively. This is not allowed because it requires that you assign two functions in two variables.

A quick example of a function that doesn't need assignment is

f = lambda x: x + 1

For it to execute on the arugment 55 , I could just write

(lambda x: x + 1)(55)

So assignment was not necessary.

Any hints on this? Or am I being tricked to an impossible problem?