mul() equivalent to sum()
This commit is contained in:
parent
12f3e58d85
commit
e54e7afd6c
@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import math
|
import math
|
||||||
from decimal import Decimal, ROUND_HALF_UP
|
from decimal import Decimal, ROUND_HALF_UP
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
|
|
||||||
def round_half_up(number: int | float) -> int:
|
def round_half_up(number: int | float) -> int:
|
||||||
@ -16,3 +17,12 @@ def get_factors(num: int) -> set:
|
|||||||
f.add(num // x)
|
f.add(num // x)
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
def mul(ints: Iterable[int]) -> int:
|
||||||
|
"""similar to sum(), just for multiplication"""
|
||||||
|
ret = 1
|
||||||
|
for x in ints:
|
||||||
|
ret *= x
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user