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
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
20, [3,5]Expected
782
Input
1, [3,5]Expected
03
Input
10, [3]Expected
184
Input
100, [3,5]Expected
23185
Input
10000, [43,47]Expected
22031606
Input
-100, [3,5,3]Expected
0Focus radio
Paused · SomaFM · Fluid