def solution(number: int) -> int:
result = 0
i = 1
if number < 0:
return 0
else:
while i < number:
if i % 3 == 0 or i % 5 == 0:
result += i
i += 1
return result
assert solution(10) == 23
assert solution(-1) == 0
assert solution(15) == 45
assert solution(200) == 9168
def solution(number):
return sum([i for i in range(number) if i % 3==0 or i % 5 == 0])
assert solution(10) == 23
assert solution(-1) == 0
assert solution(15) == 45
assert solution(200) == 9168
def solution(number: int)-> int:
result = [i for i in range(1, number) if i % 3 == 0 or i % 5 == 0]
result = sum(result)
return result
if __name__ == '__main__':
assert solution(10) == 23
assert solution(-1) == 0
assert solution(15) == 45
assert solution(200) == 9168
def solution(number):
if number < 0:
return 0
s = []
for i in range(1, number):
if i % 3 == 0 or i % 5 == 0:
s.append(i)
return sum(s)
# return sum([i for i in range(1, number) if (i % 3 == 0 or i % 5 == 0)]) if number > 0 else 0
assert solution(10) == 23
assert solution(-1) == 0
assert solution(15) == 45
assert solution(200) == 9168
public class Multiple {
public int test(int n) {
int sum = 0;
if (n < 0) {
return 0;
}
for (int i = 1; i <= n; i++) {
if ((i % 3 == 0)||(i % 5 == 0)) {
sum = sum + i;
System.out.println(sum);
}
}
return sum;
}
}