public class NumeroPrimo {
|
public boolean isPrimo(int numero) {
|
if(numero <= 1) {
|
return false;
|
}
|
for(int i = 2; i <= Math.sqrt(numero); i++) {
|
if(numero % i == 0) {
|
return false;
|
}
|
}
|
return true;
|
}
|
|
public static void main(String[] args) {
|
NumeroPrimo np = new NumeroPrimo();
|
|
int limite = Integer.parseInt(args[0]);
|
|
int conta = 1;
|
for(int i = 1; i <= limite; i++) {
|
if(np.isPrimo(i)) {
|
System.out.println(conta + " " + i );
|
conta++;
|
}
|
}
|
}
|
}
|