#include <iostream>
#include <vector>
using namespace std;
int main(){
    int M = 1e6+100;
    vector<bool> P(M,true);
    P[0] = false;
    P[1] = false;
    for(int i = 2; i*i < M; ++i){
        if(!P[i]) continue;
        for(int j = i; j*i < M; ++j){
            P[i*j] = false;
        }
    }
    int a, d, n;
    while(cin >> a >> d >> n, a||d||n){
        while(n > 0){
            while(!P[a]) a += d;
            --n;
            if(!n) cout << a << endl;
            else a += d;
        }
        //cout << a << endl;
    }
}

