Click name ↑ to return to homepage

modified from https://realpython.com/python-thinking-recursively/

```
#Global mutable state
accumulated_sum = 0
current_number = 1
final_number= 10
counter = 0
def sum_recursive():
global current_number
global accumulated_sum
global final_number
global counter
if counter == 0:
print("starting number: " + str(current_number))
print("starting sum: " + str(accumulated_sum))
print("will count up to and including: " + str(final_number))
print("we are up to number " + str(current_number))
accumulated_sum = accumulated_sum + current_number
print("sum: " + str(accumulated_sum))
if current_number == (final_number):
print("we are stopping now")
return accumulated_sum
current_number = current_number + 1
#print("next number will be : " + str(current_number))
counter += 1
return sum_recursive()
sum_recursive() #call with no arguments
```