public static boolean isPerfectSquare(long n) {
		long lastDigit = n % 10;

		if (lastDigit != 0 && lastDigit != 1 && lastDigit != 4
				&& lastDigit != 5 && lastDigit != 6 && lastDigit != 9) {
			return false;
		}

		double squareRoot = Math.sqrt(n);

		long squareRootFloor = (long) Math.floor(squareRoot);
		long squareRootCeil = (long) Math.ceil(squareRoot);

		for (long i = squareRootFloor; i <= squareRootCeil; i++) {
			if (i * i == n) {
				return true;
			}
		}

		return false;
	}