From 1193897938e5b9da62b0c2cc0b67249d263ece7b Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 27 Nov 2023 13:24:47 +0100 Subject: [PATCH] vault backup: 2023-11-27 13:24:47 --- Algo/B2/Exercises/Repetitive tutorial.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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: