Question: Python : rewrite the factorial function so that everytime it calls itself it adds an indentation ( see examples ) #here is our original definition
Python :
rewrite the factorial function so that everytime it calls itself it adds an indentation see examples
#here is our original definition
def factorial n :
if n :
return
return n factorial n
In the example below it is easy to see all the recursive calls to the factorial function.
your file must be called fact.py
in that file you must define a function called factorial
end the file with the following line so that it asks for input
for this to work your function must print something everytime it is called, and it must print something everytime it returns a value. factorialintinputenter an integer:
Examples
python fact.py
enter an integer:
factorial
factorial
factorial
factorial
factorial
returns
returns
returns
returns
returns
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
