java program for checking prime number
checking prime number
import java.util.Scanner ; class CheckPrime { public static void main ( String s[] ) { System.out.println ( " Enter a number: "); Scanner value = new Scanner ( System.in ); int number = value.nextInt ( ); int flag =0; int c = (int) Math.sqrt( number ); for ( int i = 2 ; i <=c ; i++ ) { if ( (number % i ) == 0 ) { System.out.println ( " the number" + number + " is not a prime number "); flag =1 ; break ; } } if (flag == 0 ) System.out.println ( " the number is a prime number" ); } }