login
a(n) is the least integer k such that prime(k) < (prime(n)+ prime(n+1) + ... + prime(n+k))/k <= prime(k+1).
1

%I #26 Nov 10 2024 21:45:55

%S 1,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,7,7,6,5,6,6,6,6,7,7,7,7,8,

%T 7,8,9,8,8,7,7,8,8,9,8,8,9,9,9,10,10,9,9,8,9,10,9,9,9,8,10,10,10,10,

%U 10,11,10,11,11,10,11,10,11,12,12,11,12,13,12

%N a(n) is the least integer k such that prime(k) < (prime(n)+ prime(n+1) + ... + prime(n+k))/k <= prime(k+1).

%C General property:

%C Let b(0) < b(1) < b(2) < ... be an infinite sequence of strictly positive integers. So there exists a unique integer k >= 1 such that:

%C b(k) < (b(0) + b(1) + ... + b(k))/k <= b(k+1). (See the reference.)

%H Michel Lagneau, <a href="/A247189/b247189.txt">Table of n, a(n) for n = 1..10000</a>

%H International Mathematical Olympiad 2014 <a href="https://www.imo-official.org/problems/IMO2014SL.pdf">Problem No 1</a>, Cape Town - South Africa.

%e a(3)=2 because the infinite sequence {b(0),b(1),b(2),...} = {prime(3),prime(4),...} = {5, 7, 11, 13, ...} => b(2) < (b(0) + b(1) + b(2))/2 <= b(3) => 11 < (5+7+11)/2 < 13 => 11 < 11.5 < 13. Hence a(3)=2.

%p for n from 1 to 80 do:

%p ii:=0:

%p for k from n+1 to 10^8 while(ii=0)do:

%p s:=sum('ithprime(i)', 'i'=n..k):s1:=evalf(s/(k-n)):

%p if s1<= ithprime(k+1) and s1>ithprime(k)

%p then

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

%p else

%p fi:

%p od:

%p od:

%t lst={};Do[k=n+1;While[Sum[Prime[j]/(k-n),{j,n,k}]>Prime[k+1]||Sum[Prime[j]/(k-n),{j,n,k}]<Prime[k],k++];AppendTo[lst,k-n],{n,1,50}];lst

%o (PARI) s=[];for(n=1,50,k=n+1;while(((sum(j=n, k, prime(j))/(k-n))>prime(k+1))||((sum(j=n, k, prime(j))/(k-n))<prime(k)), k++); s=concat(s, k-n)); s

%Y Cf. A000040.

%K nonn,changed

%O 1,2

%A _Michel Lagneau_, Nov 23 2014

%E Corrected by _Michel Lagneau_, Nov 20 2015