/* 
   AOJ 1141
   Dirichlet's Theorem on Arithmetic Progressions
   2015.4.29
 */

#include<stdio.h>
#define MAX_NUM 1000000
int prime_num[MAX_NUM + 1];

void generate_prime_num_table()
{
  int i, j;

  for(i = 0; i < MAX_NUM + 1; i++)
    {
      prime_num[i] = 1;
    }
  
  prime_num[0] = 0;
  prime_num[1] = 0;
  for(i = 2; i <= MAX_NUM; i++)
    {
      if(prime_num[i] == 1)
	{
	  for(j = 2; i * j <= MAX_NUM; j++)
	    {
	      prime_num[i * j] = 0;
	    }
	}
    }
  
}

int calc_prime_num(int start_num, int diff, int target_num)
{
  int i, diff_num[MAX_NUM], count = 0;
  for(i = 0; i <= MAX_NUM; i++)
    {
      diff_num[i] = 0;
    }

  for(i = 0; start_num + i * diff <= MAX_NUM; i++)
    {
      diff_num[start_num + i * diff] = 1;
    }

  /* for(i = 0; i < 100; i++) */
  /*   { */
  /*     if(diff_num[i] == 1) */
  /* 	{ */
  /* 	  printf("%3d", i); */
  /* 	} */
  /*   } */
  /* printf("\n"); */


  for(i = 0; i <= MAX_NUM; i++)
    {
      if(prime_num[i] == 1 && diff_num[i] == 1)
	{
	  count++;
	  if(count == target_num)
	    {
	      fflush(stdout);
	      return i;
	    }
	}
    }  
}

int main(void)
{
  int start_num, diff, target_num, prime_total_num;

  generate_prime_num_table();

  while(1)
    {

      scanf("%d %d %d", &start_num, &diff, &target_num);

      if(start_num == 0 && diff == 0 && target_num == 0)
	{
	  break;
	}

      prime_total_num = calc_prime_num(start_num, diff, target_num);
      printf("%d\n", prime_total_num);
    }

  return 0;
}