OFFSET
1,5
COMMENTS
We observe pairs of consecutive numbers: (6, 7), (10, 11), (19, 20), (32, 33), (93, 94), (118, 119), (242, 243), (302, 303), (215, 216), ...
As k > n we have prime(n) = m*k + n. As prime(n) > n for all n we have m >= 1 and so prime(n) >= k + n > n + n = 2*n. But prime(n) < 2*n for n <= 4 so a(n) = 0 for n <= 4. - David A. Corneth, Jul 08 2024
EXAMPLE
a(5) = 6 because prime(5) mod 6 = 11 mod 6 = 5, and there is no k < 6 such that prime(5) mod k = 5.
MAPLE
nn:=10^7:
for n from 1 to 100 do:
ii:=0:
for k from 1 to nn while(ii=0)
do:
if irem(ithprime(n), k)=n
then ii:=1:printf(`%d, `, k):
else fi:
od:
if ii=0
then printf(`%d, `, 0):
else fi:
od:
MATHEMATICA
Table[k=1; While[Mod[Prime[n], k] !=n, k++]; k, {n, 5, 70}]
PROG
(PARI) a(n) = if (n<5, 0, my(k=1); while((prime(n) % k) != n, k++); k); \\ Michel Marcus, Jul 06 2024
(PARI) first(n) = {
n = max(n, 4);
my(res = vector(n), t = 4);
forprime(p = 11, oo,
t++;
if(t > n,
return(res);
);
d = divisors(p - t);
for(i = 1, #d,
if(d[i] > t,
res[t] = d[i];
break
);
);
);
} \\ David A. Corneth, Jul 07 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Jul 06 2024
STATUS
approved