Sum the Multiples
This is a good way to practice divisibility and careful number scanning. Write a function sum_multiples_3_5 that finds the sum of all natural numbers less than n that are divisible by 3 or 5. If a number is divisible by both, count it only once. Return the final sum.
Примеры
Ввод
10Вывод
23Ввод
16Вывод
60Ввод
1000Вывод
233168Нужно реализовать
def sum_multiples_3_5(n: int) -> int:
Теги
math
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
10Expected
232
Input
16Expected
603
Input
1000Expected
2331684
Input
0Expected
05
Input
1Expected
06
Input
49Expected
543Focus radio
Paused · SomaFM · Fluid