Check Whether an Integer is prime
public static boolean prime(int d, int n) {
        if(n == 2)
            return true;
        else if(n % d == 0)
            return false;
        else if(d*d <= n)
            return prime(d+1, n);
        else
            return true;
    }
    public static boolean isPrimeLoop(int n) {
        if( n == 2)
            return true;
        for(int d=2; d*d <= n; d++) {
            if(n % d == 0)
                return false;
        }
        return true;
    }