public long kthPrimeNumber_v2(int k) {
        long[] primes = new long[k + 1];
        primes[0] = 1;
        int i3 = 0, i5 = 0, i7 = 0;
        for (int i = 1; i <= k; ++i) {
            long next = Math.min(Math.min(primes[i3] * 3, primes[i5] * 5), primes[i7] * 7);
            if (next == primes[i3] * 3)
                i3 += 1;
            if (next == primes[i5] * 3)
                i5 += 1;
            if (next == primes[i7] *  3)
                i7 += 1;
            primes[i] = next;
        }
        return primes[k];
    }