reorganise directories

upd chapter_01/binary.py
This commit is contained in:
2025-03-26 01:27:35 +00:00
parent ab09aa5269
commit 4cd7bb7d18
43 changed files with 54 additions and 53 deletions

10
chapter_03/README.md Normal file
View File

@@ -0,0 +1,10 @@
# Recursion
Recursive functions must have both:
- one or more base cases
- a recursive case
The base cases are required to ensure the recursion stops when meeting a condition
The recursive case adds functions onto the call stack and completes each one top down.

7
chapter_03/recursion.py Normal file
View File

@@ -0,0 +1,7 @@
def factorial(x):
if x == 1: # This is the base case
return 1
return x * factorial(x - 1) # This is the recursive case
print(factorial(4))