#include<stdio.h>

int prime[250000]={},num[1000000]={};
int main(void){
	int a,d,n,i,j,k=0,l,count;
	prime[k++]=2;
	prime[k++]=3;

	for(i=5;i<1000000;i+=2){
		int flag=0;
		for(j=0;i>=prime[j]*prime[j];j++){
			if(i%prime[j]==0){
				flag=1;
				break;
			}
		}
		if(flag==0){prime[k++]=i;}
	}

	
	
	for(i=0;i<k;i++){
		l=prime[i];
		num[l]=1;
	}
	
	while(1){
		count=0;
		scanf("%d %d %d",&a,&d,&n);
		if(a==0&&d==0&&n==0)break;
		for(i=a;count!=n;i+=d){
			count+=num[i];
		}
		printf("%d\n",i-d);
	}
	return 0;
}