### constant

MAX_P = 10 ** 6

### subroutines

def gen_primes(max_p)
  primes = (max_p + 1).times.map{true}
  primes[0] = primes[1] = false

  s_max_p = Math.sqrt(max_p + 0.5).to_i

  for p in (2..s_max_p)
    if primes[p]
      for q in (p * p).step(max_p, p)
        primes[q] = false
      end
    end
  end

  primes
end

### main

primes = gen_primes(MAX_P)

loop do
  a, d, n = gets.split.map(&:to_i)
  break if (a | d | n) == 0

  seq = a
  np = 0

  while np < n
    np += 1 if primes[seq]
    seq += d
  end

  puts seq - d
end