# Recursion

I tried but now l will use the vs code debugger, l don;t know how to use it but will learn now

how does i move from 0 to 1 and then back to zero in step 60 when looking at python tutor

Thanks

I find recursion very challenging

A basic recursive function calls until it reaches the base case and only then begins to actually begins to climb back up the stack. This function runs all `i=0` recursion calls until it reaches a base case and âcalculatesâ `"aaa"`. Itâs only when it starts climbing the stack that it begins running iterations on the for loop.

It seems the two default recursive examples are factorials and the Fibonacci sequence:

``````def factorial(n):
if n == 1:
return 1
return n * factorial(n-1)

print("factorial: ", factorial(3))

def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)

print("fibonacci: ", fibonacci(6))
``````

I think the difficult thing to apply to your sequencing function is that it doesnât do any calculation until the base case is reached. After that it works up the stack from the bottom.

the first finished calculation of these other functions are `factorial(1)` and `fibonacci(1)`, once a return is made it answers the previous function(s).