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-1 == j) //THE CORRECTION
{
System.out.print(" " + i);
}
}
}
}
how to get the 2 in output?
code understandingfarhat bouchnak April 30, 2012 at 9:26 PM
hi is it right to use with if only break? please help me and how?
output not correctanoop June 17, 2012 at 11:50 PM
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-1 == j) //THE CORRECTION { System.out.print(" " + i); } } } } how to get the 2 in output?
Post your Comment