From 967bb947a450d53ce9409b51ca6467409433d0c0 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 27 Nov 2023 13:46:09 +0100 Subject: [PATCH] vault backup: 2023-11-27 13:46:08 --- Algo/B2/Exercises/Repetitive tutorial.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Algo/B2/Exercises/Repetitive tutorial.md b/Algo/B2/Exercises/Repetitive tutorial.md index d00d4ba..c320b2e 100644 --- a/Algo/B2/Exercises/Repetitive tutorial.md +++ b/Algo/B2/Exercises/Repetitive tutorial.md @@ -204,6 +204,16 @@ def factorial(limit: n) -> int: return (n-1) ``` +## Exercise 2.4 +```python +def prime(n: int) -> int: + """ + Check if n(int) is prime if n > 1, error otherwise + """ + if n <= 1: + raise Exception("prime: n<= 1") + elif n % 2 == 0: + return n == 2 ## Exercise 3.3 ```python def quotient(a: int, b: int) -> int: