//
//  main.c
//  Dirichlet's Theorem on Arithmetic Progressions
//
//  Created by x15071xx on 2016/06/06.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//
//dm+a=n
//n???d??§?????£???a?????????&&?´???°?????°
#include <stdio.h>
#include <math.h>
long sosu(long a){
    long judge=1,i=3;
    double sn = sqrt(a);
    if (a == 2) {
        judge=1;
        return judge;
    }
    
    if (a<2 || a%2==0) {
        judge=0;
        return judge;
    }
    
    while (i <= sn) {
        
        if (a%i==0) {
            judge=0;
            return judge;
        }
        i+=2;
    }
    
    
    return judge;
}

int main(int argc, const char * argv[]) {
    
    long a,d,n,count_n = 0,sum=1;
    
    while (1) {
        
        scanf("%ld %ld %ld",&a,&d,&n);
        
        if(a==0&&d==0&&n==0){
            break;
        }
        
        sum=a;
        while (1) {
            long judge = sosu(sum);
            if (sum%d == a && judge==1) {
                count_n++;
                if (count_n==n) {
                    printf("%ld\n",sum);
                    break;
                }
            }
            sum+=d;
        }
        
        
        sum=0;
        count_n=0;
        
    }
    return 0;
}