#include <stdio.h>

#define N 1000001

void make_prime_flag_table(int n,int a[N]){
  int i,j;
  a[0]=a[1]=0;
  a[2]=1;
  for( i=3;i<=n;i++)
    a[i] = i&1;
  i=3;
  while( i*i<=n ){
    for( j=i<<1;j<=n;j+=i)
      a[j] = 0;
    do{ i+=2;}while(!a[i]);
  }
}


int main(void){
  int a,n,d;
  int p[N];  // prime number table 
  int i,j;

  make_prime_flag_table( N-1,p );

  while( 1 ){
    scanf("%d %d %d ",&a,&d,&n );
    if( !a && !n && !d )
      break;

    i=0;j=0;
    while( 1  ){
      if( p[a]==1 )
	j++;
      if( j==n )
	break;
      a+=d;
    }
    printf("%d\n",a );
  }
  return 0;
}