Answer the question
In order to leave comments, you need to log in
Why does the for loop work despite false?
public class JavaApplication33 {
public static void main(String[] args) {
int i, j;
boolean b;
for( i = 2; i < 100; i++) {
b = true;
//проверить, делится ли число без остатка
for ( j = 2; j <= i / j ; j++)
//если число делится без остатка, значит, оно не простое
if( ( i % j ) == 0 ) b = false;
if (b)
System.out.println( i + " - простое число" );
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question