mul() equivalent to sum()

This commit is contained in:
Stefan Harmuth 2023-12-02 07:26:47 +01:00
parent 12f3e58d85
commit e54e7afd6c

View File

@ -1,6 +1,7 @@
from __future__ import annotations
import math
from decimal import Decimal, ROUND_HALF_UP
from typing import Iterable
def round_half_up(number: int | float) -> int:
@ -16,3 +17,12 @@ def get_factors(num: int) -> set:
f.add(num // x)
return f
def mul(ints: Iterable[int]) -> int:
"""similar to sum(), just for multiplication"""
ret = 1
for x in ints:
ret *= x
return ret