#include <stdio.h>
#define number 1000000
 
char prime[number];
 
int gcd(int n, int m) {
    if(!m) return n;
    else gcd(m, n%m);
}
 
void Eratosthenes(char prime[]) {
    long i, j;
    prime[1] = 1;
    for(i = 2; i < number; i++ ) {
        if(!prime[i]) {
            //printf("%d\n",i);
            for(j = 2; j*i < number; j++ ) {
                prime[i*j] = 1;
            }
        }
    }
}
 
int main(void) {
    int a, d, n, i, count = 0;
    Eratosthenes(prime);
    while(scanf("%d%d%d",&a,&d,&n), a+d+n) {
        count = 0;
        for(i = 0; a + i*d < number; i++ ) {
            if(!prime[a + i*d]) {
                count++;
                if(count == n) {
                    printf("%d\n",a + i*d);
                    break;
                }
            }
        }
    }
    return 0;
}