process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var lines = chunk.split("\n");
  var i, len = lines.length;
  var primes = [2, 3];
  var count = 0;

  function isPrime(n) {
    if (n==1) return false;

    var i;
    
    for (i=0; i<primes.length; i++) {
      if (n % primes[i] === 0) {
        return false;
      }
    }
    return true;
  }
  
  for (i=0; i<len; i++) {
    var line = lines[i].split(' ');
    var a = line[0] * 1;
    var b = line[1] * 1;
    var n = line[2] * 1;
    var ans = 0;

    if (!a && !b && !n) {
      break;
    }

    var cnt = 0;
    while (cnt != n) {
      var root = ~~Math.sqrt(a);
      var maxPrime = primes[primes.length-1];
      
      if ( maxPrime < root) {
        for (var j = maxPrime; j <= root; j+=2 ) {
          if (primes.indexOf(j) == -1 && isPrime(j)) {
            primes.push(j);
          }
        }
      }

      if (primes.indexOf(a) > -1 || isPrime(a)) {
       cnt++;
       ans = a;
      } 

      a += b;
    }
    console.log(ans);
  }
});