#include<stdio.h>
#define MAX 1000000

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

void calculate()
{
    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 i;
    prime[2]=0;
    prime[1]=0;

    calculate();

    while(1)
    {
        int count=0,a,d,n;

        scanf("%d %d %d",&a,&d,&n);

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

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