#include<stdio.h>
#define MAX 1000000

int prime[MAX]={};      //?´???°?????´??????0???????????§????????´??????1

void calculate(void)
{
    int i,j,k;

    for(i=2;i<MAX;i++)
    {
        if(prime[i]==0)
        {
            k=i*2;
            for(j=k;j<MAX;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    return;
}

int main(void)
{
    int count=0,a=0,d=0,n=0;
    calculate();

    while(1)
    {
        count=0;
        prime[1]=1;
        scanf("%d %d %d",&a,&d,&n);

        if(a==0 && d==0 && n==0)
        {
            break;
        }

        while(count!=n)
        {
            if(prime[a]==0)
            {
                count++;
            }
            a+=d;
        }
        printf("%d\n",a-d);
    }
    return 0;
}