We would like to write a program that displays all the numbers from 100 to 1,000, that are divisible by 5 and 6.
public class Main { public static void main(String[] args) { int numCount = 1; for (int i = 100; i <= 1000; i++) { //your code here }/*from w ww . ja v a 2 s. co m*/ } }
public class Main { public static void main(String[] args) { int numCount = 1; for (int i = 100; i <= 1000; i++) { if (i % 5 == 0 && i % 6 == 0) System.out.print((numCount++ % 10 != 0) ? i + " " : i + "\n"); } } }