#include <stdio.h>

int main(void)
{
  int a,d,n,i,j,k,l=0,tmp,count=0;
  int prime[100001];
  for(i=2;i<=100000;i++)
    {
      prime[i]=1;
    }
  prime[0] = 0;
  prime[1] = 0;

  for(;;){
    l=0;
    scanf("%d %d %d",&a,&d,&n);
    if(a == 0 && d ==0 && n==0){return 0;}
    //printf("1");
    count = 0;
    for(i=0;;i++)
      {
	tmp = a+d*i;
	if(prime[tmp]){
	  for(j=2;j<tmp;j++)
	    {
	      if(tmp % j == 0)
		{
		  prime[tmp]=0;
		  for(k=tmp;k<=100000;k+=tmp)
		    {
		      prime[k]=0;
		    }
		  break;
		}
	      else if(j==(tmp-1)){
		count++;
		//printf("%d\n",count);
		if(count == n){
		  l=1;
		  printf("%d\n",tmp);
		  break;
		}
	      }
	    }
	}
	if(l==1){break;}
      }
  }
}