#include<stdio.h>

int dirichlet(int a,int d,int n,int sosu_c[]){
  int count = 0;
  while(1){
    if(sosu_c[a]==1)count++;
    if(count==n)return a;
    a = a + d;
  }
}

int main(void){
  int a[1024],d[1024],n[1024];
  int i,j;
  int count;
  int sosu_c[1000000] = {};

  sosu_c[2] = 1;

  for(i=3;i<1000000;i=i+2){
    sosu_c[i] = 1;
  }
  for(i=3;i*i<1000000;i=i+2){
    if(sosu_c[i]==1){
      for(j=i*i;j<1000000;j=j+(i*2)){
	sosu_c[j] = 0;
      }
    }
  }

  for(i=0;i>=0;i++){
    scanf("%d%d%d",&a[i],&d[i],&n[i]);
    if(a[i]==0&&d[i]==0&&n[i]==0)break;
  }
  count = i;

  for(i=0;i<count;i++){
    printf("%d\n",dirichlet(a[i],d[i],n[i],sosu_c));
  }
  return 0;
}