This program is supposed to print out prime numbers from 1 to 50:
public class Break{
public static void main(String[] args){
int i,j;
System.out.println("Prime numbers between 1 to 50 : ");
for (i = 1;i < 50;i++ ){
for (j = 2;j < i;j++ ){
if(i % j == 0)
{
break;
}
}
if(i == j)
{
System.out.print(" " + i);
}
}
}
}
But why do i have to declare two variables j and i and the get the remainder, and also create loops for each one of them can someone please explain?