OFFSET
1,3
COMMENTS
The sequence presents a pattern with large discontinuities at regular intervals in the logarithmic plot (See plots in Links).
LINKS
FORMULA
a(n) = Min_{k | (n+1) divides (prime(n)+k)}.
a(n) = (n+1)*ceiling(prime(n)/(n+1)) - prime(n)
EXAMPLE
The following table shows the first 10 terms where the fourth column, a(n), plus the third column, prime(n), is divisible by the second column n+1:
n n+1 prime(n) a(n)
1 2 2 0
2 3 3 0
3 4 5 3
4 5 7 3
5 6 11 1
6 7 13 1
7 8 17 7
8 9 19 8
9 10 23 7
10 11 29 4
MATHEMATICA
a[n_]:=Module[{k}, k=0;
While[Mod[Prime[n]+k, n+1]!=0, k++]; k];
Table[a[n], {n, 1, 70}]
PROG
(Python)
from sympy import prime
def A364633(n): return (n+1)*(prime(n)//(n+1)+1)-prime(n) if n>2 else 0 # Chai Wah Wu, Sep 04 2023
(PARI) a(n) = my(k=0, p=prime(n)); while ((p+k) % (n+1), k++); k; \\ Michel Marcus, Sep 05 2023
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Andres Cicuttin, Jul 30 2023
STATUS
approved