Aug-16-2020, 08:51 PM
Doesn't work for me either way.
This is not exactly recursion. A recursive function defines its result in terms of itself;
However, you can do what you want by getting rid of the loop and calling the function like this:
This is not exactly recursion. A recursive function defines its result in terms of itself;
Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2)
. Yours is just a strange while loop that returns no result and the only result is a side effect..However, you can do what you want by getting rid of the loop and calling the function like this:
def recsum (entnf,sumf): """Prints 0 to entnf" if sumf <= entnf: print("Sum is: ", sumf) recsum(entnf,sumf + 1) recsum(int(input('Enter a number ')),0)