#include <stdio.h>

#include <stdbool.h>

int main(){
	int b=0,c;
	
	int i;
	bool a[1000001];
	
	for(b=0;b<1000001;b++){
		a[b]=1;
	}
	a[0]=0;a[1]=0;
	b=0;
	do{
		if(a[b]==1){
			c=2;
			while(b*c<1000001){
				a[b*c]=0;
				c++;
			}
		}
		b++;
		
	}while(b<500001);
	
	/*for(b=0;b<1000001;b++){
		if(a[b]==1){
			printf("%d\n",b);
		}
	}*/
	
	
	int x,y,z;
	while(1){
		scanf("%d %d %d",&x,&y,&z);
		if(x==0){
			break;
		}
		i=0;
		while(z!=0){
			if(a[x+y*i]){
				z--;
			}
			i++;
		}
		printf("%d\n",x+y*(i-1));
	}
	
	
	return 0;
}