OFFSET
1,3
LINKS
Robert Israel, Table of n, a(n) for n = 1..282
FORMULA
a(n) = min {k : A013632(k) = n}.
EXAMPLE
+------+------+-----+
| a(n) | next | gap |
| | prime| |
+------+------+-----+
| 1 | 2 | 1 |
| 0 | 2 | 2 |
| 8 | 11 | 3 |
| 7 | 11 | 4 |
| 24 | 29 | 5 |
| 23 | 29 | 6 |
| 90 | 97 | 7 |
| 89 | 97 | 8 |
+------+------+-----+
MAPLE
N:= 100:
A:= Vector(N, -1):
count:= 0: lastp:= 0:
while count < N do
p:= nextprime(lastp);
newvals:= select(t -> A[t]=-1, [$1..min(p-lastp, N)]);
count:= count+nops(newvals);
for k in newvals do A[k]:= p-k od;
lastp:= p;
od:
convert(A, list); # Robert Israel, Aug 23 2019
MATHEMATICA
Table[SelectFirst[Range[0, 20000], NextPrime[#] - # == n &], {n, 1, 50}]
PROG
(PARI) a(n) = my(k=0); while(nextprime(k+1) - k != n, k++); k; \\ Michel Marcus, Aug 21 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Aug 21 2019
STATUS
approved