diff --git a/src/tools/math.py b/src/tools/math.py index f98c5b7..6a58baf 100644 --- a/src/tools/math.py +++ b/src/tools/math.py @@ -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