src/com/michaelho/RandomizedAlgorithms/RA2.java
/**
         * Determine if the number is a prime number.
         *
         * @param n The number to be determined.
         * @return a boolean indicate whether the number is a prime number.
         * */
Determine if the number is a prime number.
@param n The number to be determined.
@return a boolean indicate whether the number is a prime number.
Determine if the number is a prime number . @param n The number to be determined . @return a boolean indicate whether the number is a prime number .
boolean isPrime(int n) {
            if (n <= 1) return false;
            for (int i = 2; i*i < n; i++)
                if (n % i == 0)
                    return false;
            return true;
        }
boolean isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; }
Determine if the number is a prime number.
Determine if the number is a prime number .
// Corner case