29 lines
939 B
Java
29 lines
939 B
Java
package capitulo03.bloque04;
|
|
|
|
import static capitulo03.utils.Utils.solicitarIntScanner;
|
|
|
|
public class Ejercicio2 {
|
|
public static void main(String[] args) {
|
|
int limiteMin = solicitarIntScanner("Introduzca un número desde el que empezar a comprobar los primos"),
|
|
limiteMax = solicitarIntScanner("Introduzca un número en el que terminar de comprobar los primos");
|
|
|
|
int tempVar = 2;
|
|
|
|
while (limiteMin <= limiteMax) {
|
|
while (tempVar <= limiteMin) {
|
|
if (tempVar == limiteMin) {
|
|
System.out.println(limiteMin + " es un número primo");
|
|
break;
|
|
} else if (limiteMin % tempVar == 0) {
|
|
System.out.println(limiteMin + " es un número compuesto");
|
|
break;
|
|
}
|
|
tempVar++;
|
|
}
|
|
limiteMin++;
|
|
tempVar = 2;
|
|
}
|
|
}
|
|
}
|
|
|