Add Matching Multiples

Sometimes you need to add numbers that match one of several rules, like all values divisible by 3 or 5. The function sum_of_multiples receives a limit and a list of factors multiples, then finds all unique natural numbers below limit that are divisible by at least one of those factors. Do not add the same number twice, even if it matches several factors.

Примеры

Ввод
(20, [3, 5])
Вывод
78
Ввод
(1, [3, 5])
Вывод
0
Ввод
(10, [3])
Вывод
18

Нужно реализовать

def sum_of_multiples(limit: int, multiples: list[int]) -> int:

Теги

math
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
20, [3,5]
Expected78
2
Input
1, [3,5]
Expected0
3
Input
10, [3]
Expected18
4
Input
100, [3,5]
Expected2318
5
Input
10000, [43,47]
Expected2203160
6
Input
-100, [3,5,3]
Expected0
Focus radio
Paused · SomaFM · Fluid