Multiples of 3 and 5

Answer is 233168 pragmatically.

I did not use the Math to get the answer.

public class Main {
public static int multiple3and5below1000() {
int sum = 0;
for (int i = 3; i < 1000; i++) {
if ((i >= 3 && ((i % 3) == 0) || (i >= 5 && ((i % 5) == 0))))
sum += i; }
return sum; }
public static void main(String[] args) {
System.out.println(multiple3and5below1000()); }
}

### Like this:

Like Loading...

*Related*