require "prime"

ary = []
STDIN.each do |l|
  ary << l.split(" ").map(&:to_i)
end
ary.each do |a,d,n|
  break if (a == 0) && (d == 0) && (n == 0)
  count = 0
  res = a
  count += 1 if Prime.prime? res
  begin
    res += d
    count += 1 if Prime.prime? res
  end while count < n
  puts res
end