object Main {
    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 (a <- in if a(0) != 0) println(Stream.from(0).map(a(0) + a(1) * _).filter(isPrime)(a(2)-1))
    }
}