Multiples 3 and 5
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++;
}
}
}
Multiples 3 and 5 for
public class Main
{
public static void main(String[] args)
{
int i = 1;
for (i = 1; i <= 500; i++)
{
if ((i % 3 == 0) && (i % 5 == 0))
{
System.out.printf("%1$s ", i);
}
}
}
}
Multiples 3 and 5 for step 15
public class Main
{
public static void main(String[] args)
{
for (int i = 15; i <= 500; i += 15)
{
System.out.printf("%1$s ", i);
}
}
}