completed multiples of 3 and 5
This commit is contained in:
parent
f336388709
commit
8e77b319b3
@ -3,8 +3,20 @@ package multipleof3and5;
|
|||||||
public class Multiples {
|
public class Multiples {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user