Atom

Recursion

Recursion is when a function calls itself to solve a smaller part of the same problem. Give it a stopping case so it does not keep calling itself indefinitely.

Add the integers from one to a limit

Each call decreases the limit until it reaches zero.

Atom
func total(limit):
    if limit == 0:
        return 0
    return limit + total(limit - 1)

print(total(4))
Output
10

The calls build 4 + 3 + 2 + 1 + 0. The zero case stops the recursion.