Ok so i made this program that verify if a number is prime.I can't figure out how to make a program that can verify that all numbers < n are prime.Can you help me ?
import javax.swing.*;
public class Main {
public static void main(String[] args) {
int i;
int n;
boolean nPrime=true;
n = Integer.parseInt(JOptionPane.showInputDialog("Entrer un numero"));
for (i = 2; i < n; i++) {
if (n % i == 0) {
nPrime = false;
}
}
if (nPrime) {
System.out.println("Le numero " + n + " est prime");
} else
System.out.println("Le numero " + n + " n'est pas prime");
}
}