<jupyter_start><jupyter_text>Recursion "When you write a recursive function, you have to tell it when to stop recursing. That’s why every recursive function has two parts: the base case, and the recursive case. The recursive case is when the function calls itself. The base case is when the function doesn’t call itself again ... so it doesn’t go into an infinite loop."<jupyter_code>def countdown(i): 
    print(i)
    if i<= 0:
        return
    else:
        countdown(i-1)
countdown(5)<jupyter_output>5
4
3
2
1
0<jupyter_text>The call stack with recursion<jupyter_code># factorial function wiwh recursion
def fact(x):
    if x == 1:
        return 1
    else:
        return x * fact(x-1)
fact(5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08071135430916553, 'fraction_numerical': 0.017783857729138167, 'mean_word_length': 3.632911392405063, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '512311', 'license': 'MIT', 'n_tokens_mistral': 249, 'n_tokens_neox': 235, 'n_words': 93, 'path': '3_Recursion.ipynb', 'repo_name': 'ogulkokan/Algorithms', 'size': '731'}