#include <stdio.h>

#define N 1000000

int p[ N ] = { 1, 1, 0 };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( j = 2; j < N; ++j )
  {
    if ( p[ j ] ) continue ;

    for ( i = j * 2; i < N; i += j )
    {
      p[ i ] = 1;
    }
  }

  for ( ; ; )
  {
    int a, d, n;

    scanf ( "%d%d%d", &a, &d, &n );
    if ( !( a | d | n ) ) break ;

    for ( ; n; a += d )
    {
      n -= !p[ a ];
    }

    printf ( "%d\n", a - d );
  }

  return ( 0 );
}