completed multiples of 3 and 5

This commit is contained in:
aj 2019-02-08 14:56:20 +00:00
parent f336388709
commit 8e77b319b3

View File

@ -3,8 +3,20 @@ package multipleof3and5;
public class Multiples {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hello world");
int upperBound = 1000;
int total = 0;
int counter;
for(counter = 0; counter < upperBound; counter++) {
if(counter % 3 == 0 || counter % 5 == 0) {
total += counter;
}
}
System.out.println("The total of multiples of 3 and 5 below " + upperBound + " is " + total);
}
}