Exercise
Multiples
Objetive
Create a java program to display on the screen the numbers from 1 to 500 that are multiples of both 3 and 5. (Hint: Use the modulo operator to check for divisibility by both 3 and 5.)
Example Code
public class Main
{
public static void main(String[] args)
{
int i = 1;
while (i <= 500)
{
if ((i % 3 == 0) && (i % 5 == 0))
{
System.out.printf("%1$s ", i);
}
i++;
}
}
}