#K84672. Sum of Multiples
Sum of Multiples
Sum of Multiples
Given an array of integers, you are required to compute the sum of all elements that are multiples of 3 or 5. An integer x is considered a multiple of 3 if \(x \mod 3 = 0\) and a multiple of 5 if \(x \mod 5 = 0\). Note that the array may contain negative numbers and zero. Your program should process multiple test cases.
Task: For each test case, implement the logic to sum all numbers in the array that satisfy the condition above, and output the result.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(T\), which indicates the number of test cases.
- For each test case:
- The first line contains an integer \(N\), the number of elements in the array.
- The second line contains \(N\) space-separated integers.
outputFormat
For each test case, output a single integer on a new line representing the sum of all elements that are multiples of 3 or 5. Use standard output (stdout) for printing the results.
The conditions can be mathematically represented as:
\(x\) is included if \(x \mod 3 = 0\) or \(x \mod 5 = 0\).
## sample5
10
1 2 3 4 5 6 7 8 9 10
5
1 2 4 7 11
6
-3 -5 -6 7 8 15
5
0 3 5 10 15
4
-15 -5 5 15
33
0
1
33
0
</p>