#include<stdio.h>
#define M 1001000
int main(){
  int i,j,a,b,c;
  char p[M]={1,1};
  for(i=2;i*i<M;i++){
    if(p[i])continue;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  while(scanf("%d %d %d",&a,&b,&c),a||b||c){
    for(;c--;a+=b)c+=p[a];
    printf("%d\n",a-b);
  }
  return 0;
}