Result
class Test{
public static void main(String args[]){
display(44);
display(5);
display(46487);
display(99557865459558797l);
}
private static void display(long Num){
if( isPrimeNum( Num ) ) {
System.out.println( Num + " is a prime number." );
} else{
System.out.println( Num +" isn't a prime number.");
}
}
private static boolean isPrimeNum( long x ) {
if( x == 2 )
return true;
if( x < 2 || x % 2 == 0 )
return false;
for( long a = 3; a <= Math.sqrt((double)x); a += 2 )
if( x % a == 0 )
return false;
return true;
}
}