在线编译器 Python

# 4. Факториал def fact(n): return 1 if n <= 1 else n * fact(n - 1) print(fact(5))
This code defines a recursive function that computes the factorial of a number, then prints the factorial of 5.

- The base case returns 1 when n is 1 or less, which correctly stops the recursion.
- Check whether the recursion actually reaches that base case for the input you pass, and trace the multiplication chain to confirm the result matches the expected factorial.