I was practising the prime numbers code simultaneously and for some reason that I can’t figure out my program wasn’t running and giving an error which said “n” command not found. The code is as follows could someone help correct it please.
import java.util.Scanner;
public class Prime
{
public static void main(String[] args)
{
Scanner scn = new Scanner(System.in);
int n = scn.newInt();
int d = 2;
boolean flag = true;
while(d <= n-1)
{
if(n % d == 0)
{
flag = false;
}
d = d + 1;
}
if (flag == true)
{
System.out.println("Number is prime");
}
else
{
System.out.println("Not prime");
}
}
}