#20131025
#a d n
#a<=9370
#d<=346
#n<=210

#Eratosthenes
Max=1000000
prime=Array.new Max
prime[0]=prime[1]=false
prime[2]=true
index=4
while index<prime.length
	prime[index] = false
	index+=2
end
1.upto(Max/2-1){|i|
	num=i*2+1
	if prime[num] == nil
		prime[num] = true
		index = num*2
		while index < Max
			prime[index]=false
			index+=num
		end
	end
}

while true
	a,d,n = gets.split(" ").map{|e|e.to_i}
	break if a==0 && d==0 && n==0

	num=a
	while num < Max && n != 0
		if prime[num] 
			n-=1
			ans=num
		end
		num+=d
	end
	p ans
end