object Main {
  def is_prime(i: Int): Boolean = {
    var x = 2
    while(i >= x * x) {
      if(i % x == 0) return false
      x += 1
    }
    true
  }

  def from(n: Int): Stream[Int] = Stream.cons(n, from(n + 1))

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    var a, d, n = sc.nextInt
    while(a != 0 || d != 0 || n != 0) {
      println(from(2).filter(x => x >= a && (x - a) % d == 0 && is_prime(x)).take(n).last)
      a = sc.nextInt; d = sc.nextInt; n = sc.nextInt
    }
  }
}