OFFSET
1,2
COMMENTS
General property:
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:
b(k) < (b(0) + b(1) + ... + b(k))/k <= b(k+1). (See the reference.)
LINKS
Michel Lagneau, Table of n, a(n) for n = 1..10000
International Mathematical Olympiad 2014 Problem No 1, Cape Town - South Africa.
EXAMPLE
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.
MAPLE
for n from 1 to 80 do:
ii:=0:
for k from n+1 to 10^8 while(ii=0)do:
s:=sum('ithprime(i)', 'i'=n..k):s1:=evalf(s/(k-n)):
if s1<= ithprime(k+1) and s1>ithprime(k)
then
printf(`%d, `, k-n):ii:=1:
else
fi:
od:
od:
MATHEMATICA
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
PROG
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Nov 23 2014
EXTENSIONS
Corrected by Michel Lagneau, Nov 20 2015
STATUS
approved