public long GetLargestPrimeFactor(long maxValue) {
        if (knownPrimes.size() > 0) {
            if (maxValue < (knownPrimes.get(knownPrimes.size() - 1))) {
                for (int knowPrimeIndex = knownPrimes.size() - 1; knowPrimeIndex > 0; knowPrimeIndex--) {
                    if ((knownPrimes.get(knowPrimeIndex) <= maxValue) &&
                            ((maxValue % (knownPrimes.get(knowPrimeIndex))) == 0))
                        return knownPrimes.get(knowPrimeIndex);
                }
            }
        }
        for (int i = 2; i < maxValue; i++) {
            if (IsPrime(i)) {
                if (maxValue % i == 0) {
                    return GetLargestPrimeFactor(maxValue / i);
                }
            }
        }
        return maxValue;
    }