OFFSET
1,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = A228325(n) - n for n > 1.
EXAMPLE
33 is not prime. 34 is not prime. 35 is not prime. 36 is not prime. 37 is prime. Since 7 is 4 more than 3, a(3) = 4.
MAPLE
a:= proc(n) local j; for j from n do if isprime(n*10^(1+ilog10(j))+j) then return(j-n) fi od end proc:
seq(a(n), n=1..100); # Robert Israel, Jul 30 2014
MATHEMATICA
lnk[n_]:=Module[{k=0, idn=IntegerDigits[n]}, While[!PrimeQ[FromDigits[ Join[ idn, IntegerDigits[ n+k]]]], k++]; k]; Array[lnk, 90] (* Harvey P. Dale, Oct 05 2014 *)
PROG
(PARI)
a(n) = for(k=n, 10^4, if(isprime(eval(concat(Str(n), Str(k)))), return(k-n)))
vector(150, n, a(n))
(Python)
def a(n):
..for k in range(n, 10**4):
....if isprime(str(n)+str(k)):
......return k-n
n = 1
while n < 150:
..print(a(n), end=', ')
..n += 1
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Derek Orr, Jul 30 2014
STATUS
approved