login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Least k such that prime(n) mod k = n or 0 if no such k exists.
1

%I #32 Dec 12 2024 18:25:28

%S 0,0,0,0,6,7,10,11,14,19,20,25,14,29,16,37,21,43,24,51,26,57,30,65,36,

%T 75,38,79,40,83,32,33,52,35,38,115,40,125,64,133,46,139,74,149,76,51,

%U 82,175,89,179,91,187,94,197,101,69,106,71,109,221,74,77,122,247

%N Least k such that prime(n) mod k = n or 0 if no such k exists.

%C We observe pairs of consecutive numbers: (6, 7), (10, 11), (19, 20), (32, 33), (93, 94), (118, 119), (242, 243), (302, 303), (215, 216), ...

%C 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

%H David A. Corneth, <a href="/A374353/b374353.txt">Table of n, a(n) for n = 1..10000</a>

%e 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.

%p nn:=10^7:

%p for n from 1 to 100 do:

%p ii:=0:

%p for k from 1 to nn while(ii=0)

%p do:

%p if irem(ithprime(n),k)=n

%p then ii:=1:printf(`%d, `,k):

%p else fi:

%p od:

%p if ii=0

%p then printf(`%d, `,0):

%p else fi:

%p od:

%t Table[k=1;While[Mod[Prime[n],k] !=n,k++];k,{n,5,70}]

%o (PARI) a(n) = if (n<5, 0, my(k=1); while((prime(n) % k) != n, k++); k); \\ _Michel Marcus_, Jul 06 2024

%o (PARI) first(n) = {

%o n = max(n, 4);

%o my(res = vector(n), t = 4);

%o forprime(p = 11, oo,

%o t++;

%o if(t > n,

%o return(res);

%o );

%o d = divisors(p - t);

%o for(i = 1, #d,

%o if(d[i] > t,

%o res[t] = d[i];

%o break

%o );

%o );

%o );

%o } \\ _David A. Corneth_, Jul 07 2024

%Y Cf. A000040, A014689.

%K nonn

%O 1,5

%A _Michel Lagneau_, Jul 06 2024