vault backup: 2023-11-20 13:43:12

This commit is contained in:
Louis Gallet 2023-11-20 13:43:12 +01:00
parent 26b0afcfb8
commit f638273eed
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

View File

@ -17,8 +17,9 @@ The function return the sum of the factorial of n
``` ```
def multiplication(x: int, y: int) -> int: def multiplication(x: int, y: int) -> int:
result = 0 result = 0
for i in range(y): while y > 0:
result = result + x m += x
y -= 1
return result return result
def multiplication2(x: int, y: int) -> int: def multiplication2(x: int, y: int) -> int:
@ -44,6 +45,14 @@ def multiplication2(x: int, y: int) -> int:
result = result + x result = result + x
i += 1 i += 1
return result return result
def multiplication2(x: int, y: int) -> int:
if x < 0 and y < 0:
return multiplication(-x, -y) * (-1)
elif y < 0:
return multiplication(x, -y) * (-1)
else
return multiplication(x, y)
``` ```
## Exercise 1.3 ## Exercise 1.3