1.

Please check the error in my java program for checking whether the number is prime or notimport java.util.*;class prime_number{public static void main(){Scanner sc=new Scanner (System.in);int n=sc.nextInt();//n is the inputint i=1;//variableint m=0;//variablefor(i=1;iif(n%i==0){m=m+1;}}if(m==0){ System.out.println(n+" is a prime number");}else{System.out.println(n+" is not a prime number");}}}

Answer»

Answer:

The prime NUMBER program is an indispensable part of learning Java. HENCE, most of the great BOOKS on Java covers it. Before moving FORWARD to discuss the prime number program in Java, let’s first understand the concept of prime numbers and their importance.



Discussion

No Comment Found