diff --git a/Algo/B2/Exercises/Repetitive tutorial.md b/Algo/B2/Exercises/Repetitive tutorial.md index 1bcee11..d00d4ba 100644 --- a/Algo/B2/Exercises/Repetitive tutorial.md +++ b/Algo/B2/Exercises/Repetitive tutorial.md @@ -187,6 +187,23 @@ def mirror(n: int) -> int; return res ``` +## Exercise 2.3 +```python +def factorial(limit: n) -> int: + n = 0 + if limit <= n: + return n + else: + f = 1 + while f < limit: + n += 1 + f *= n + if n % 2 == 0: + return (n-2) + else: + return (n-1) +``` + ## Exercise 3.3 ```python def quotient(a: int, b: int) -> int: