object Main {
    val hm = scala.collection.mutable.HashMap[Int, Boolean]()
    def isPrime(n: Int) = n > 1 && (2 to math.sqrt(n).toInt).forall(n % _ != 0)
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        for (Array(a, d, n) <- in if a != 0) println(Stream.from(0).map(a + d * _).filter(m => hm.getOrElseUpdate(m, isPrime(m)))(n-1))
    }
}