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
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
10
Expected23
2
Input
16
Expected60
3
Input
1000
Expected233168
4
Input
0
Expected0
5
Input
1
Expected0
6
Input
49
Expected543
Focus radio
Paused · SomaFM · Fluid