public static boolean isPrime ( int a ) {
	// avoid the problem caused by negtive numbers
	a = Math.abs(a);
	boolean prime = true;
	for ( int i=2; i<=Math.sqrt(a); i++ ) {
	    if ( a%i == 0 ) {
		prime = false;
	    }
	}
	return prime;
    }