def isPrime(n):

    f = [True]*(n+1)

    f[0] = f[1] = False

    for i in range(2,int(n**0.5)+1):

        if f[i]:

            for j in range(i**2, n+1, i): f[j] = False

    return f



l = isPrime(1000000)

while True:

    a,d,n = list(map(int,input().split()))

    if not(n): break

    cnt = 0

    while True:

        if l[a]: cnt += 1

        if cnt==n: break

        a += d

    print(a)

    
def prime(n):

    flag = [True]*(n+1)

    flag[0] = flag[1] = False

    for i in range(2,int(n**0.5)+1):

        if flag[i]:

            for j in range(i**2, n+1, i):

                flag[j] = False

    return flag

flag = prime(1000000)

while True:

    a,d,n = list(map(int,input().split()))

    if n==0: break

    i,c = 0,0

    while c<n:

        if flag[a+d*i]: c+= 1

        i += 1

    print((a+d*(i-1)))
def isPrime(n):
    f = [True] * (n + 1)
    f[0] = f[1] = False
    for i in range(2, int(n**0.5) + 1):
        if f[i]:
            for j in range(i**2, n + 1, i):
                f[j] = False
    return f


l = isPrime(1000000)
while True:
    a, d, n = list(map(int, input().split()))
    if not (n):
        break
    cnt = 0
    while True:
        if l[a]:
            cnt += 1
        if cnt == n:
            break
        a += d
    print(a)

def prime(n):
    flag = [True] * (n + 1)
    flag[0] = flag[1] = False
    for i in range(2, int(n**0.5) + 1):
        if flag[i]:
            for j in range(i**2, n + 1, i):
                flag[j] = False
    return flag


flag = prime(1000000)
while True:
    a, d, n = list(map(int, input().split()))
    if n == 0:
        break
    i, c = 0, 0
    while c < n:
        if flag[a + d * i]:
            c += 1
        i += 1
    print((a + d * (i - 1)))

-def isPrime(n): -    f = [True] * (n + 1) -    f[0] = f[1] = False +def prime(n): +    flag = [True] * (n + 1) +    flag[0] = flag[1] = False -        if f[i]: +        if flag[i]: -                f[j] = False -    return f +                flag[j] = False +    return flag -l = isPrime(1000000) +flag = prime(1000000) -    if not (n): +    if n == 0: -    cnt = 0 -    while True: -        if l[a]: -            cnt += 1 -        if cnt == n: -            break -        a += d -    print(a) +    i, c = 0, 0 +    while c < n: +        if flag[a + d * i]: +            c += 1 +        i += 1 +    print((a + d * (i - 1)))