Write a function:
class Solution { public int solution (int[] A); }
that, given an array A consisting of N integers, returns the sum of all integers which are multiples of 4.
class Solution {
public int solution(int[] A) {
int total = 0;
for (int a : A) {
if (a % 4 == 0) {
total += a;
}
}
return total;
}
}
Comments
Leave a comment