#include<stdio.h>
bool isprime(int n,int k=2){if(n==1){return false;}if(n<k*k){return true;}if(n%k==0){return false;}return isprime(n,k+1);}int main(){int a,d,n,c;while(true){scanf("%d%d%d",&n,&d,&a);if(n==0){break;}c=0;while(c<n){if(isprime(a)){c++;}a+=d;}printf("%d\n",a-d);}}