// Aizu 1141: Dirichlet's Theorem on Arithmetic Progre...
// 2017.9.13 bal4u@uu

#include <stdio.h>

#define MAX  1000000
#define SQRT 1000     // sqrt(MAX)
char prime[MAX + 5], *p, *q, *pmax = prime + MAX;

void mkprime()
{
	int k;
	prime[1] = 1; for (p = prime + 4; p <= pmax; p += 2) *p = 1;
	for (k = 3, p = prime + 3; k <= SQRT; k += 2, p += 2)
		if (!*p) for (q = p + k; q <= pmax; q += k) *q = 1;
}

int main()
{
	int a, d, n;

	mkprime();
	while (scanf("%d%d%d", &a, &d, &n) && a) { a -= d;
		while (n > 0) {
			a += d;
			if (!prime[a]) n--;
		}
		printf("%d\n", a);
	}
	return 0;
}