From 65c850800cc34948366f5bd79130f4e4309a12e2 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 24 Nov 2023 16:02:14 +0100 Subject: [PATCH] vault backup: 2023-11-24 16:02:14 --- Algo/B2/Exercises/Repetitive tutorial.md | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Algo/B2/Exercises/Repetitive tutorial.md b/Algo/B2/Exercises/Repetitive tutorial.md index 8b365ad..1bcee11 100644 --- a/Algo/B2/Exercises/Repetitive tutorial.md +++ b/Algo/B2/Exercises/Repetitive tutorial.md @@ -160,7 +160,7 @@ def mu_sum(n: int) -> int: ```python def euclid(a, b): if (a <= b): - raise ValueError("a must be superior to b") + raise Exception("a must be superior to b") r = 1 while r != 0: oldr = r @@ -175,4 +175,25 @@ def euclid(a, b): while b != 0: (a, b) = (b, a%b) return a -``` \ No newline at end of file +``` + +## Exercise 2.2 +```python +def mirror(n: int) -> int; + res = 0 + while n != 0: + res = res * 10 + n % 10 + n //= 10 + return res +``` + +## Exercise 3.3 +```python +def quotient(a: int, b: int) -> int: + q = 0 + if (a < b): + (a, b) = (b, a) + while (a-b) >= 0: + q += 1 + a -= b + return q