/*
* Print the numbers 1 to 100 (inclusive) each number on its own line.
* If a number is evenly divisable by 3 print "foo" instead.
* If a number is evenly divisable by 5 print "bar" instead.
* If a number is evenly divisable by 3 and 5 print "foobar" instead.
*/
public class LoopingFun {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (0 != i % 3 && 0 != i % 5) System.out.print(i);
if (0 == i % 3) System.out.print("foo"); // used print instead of println
if (0 == i % 5) System.out.print("bar"); // so foo and bar go on the same line
System.out.println(); // adds the newline that is missing above
}
}
}