import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    auto s = new bool[](10^^6 + 1);
    s[] = 1;
    s[0] = s[1] = 0;

    for (int p = 2; p*p <= 10^^6; p++) {
        if (s[p]) {
            for (int q = p*p; q <= 10^^6; q += p) {
                s[q] = 0;
            }
        }
    }

    while (1) {
        int a, d, n;
        scan(a, d, n);

        if (!a) return;

        int m;

        while (m < n) {
            if (s[a]) m++;
            a += d;
        }

        a-=d;

        writeln(a);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}