matura/main.py

15 lines
295 B
Python
Raw Normal View History

2024-05-21 07:17:59 +00:00
def iloczyn(x: int ,y: int ) -> int:
if y == 1:
return x
else:
k = y // 2
z = iloczyn(x,k)
if y % 2 == 0:
return z + z
else:
return x + z + z
print(iloczyn(9,11))
print(iloczyn(9,5))
print(iloczyn(9,2))
print(iloczyn(9,1))