OFFSET
1,1
COMMENTS
The average of the prime numbers up to m is asymptotically equal to m/2 by the prime number theorem. It is shown by Mandl's inequality that m/2 is strictly greater than the average if m > 19 and thus the sequence is complete.
LINKS
Hassani Mehdi, A Refinement of Mandl's Inequality, report collection, 8 (2) (2005).
Eric Bach and Jefrey Shallit, Algorithmic Number Theory, Vol. 1: Efficient Algorithms, Section 2.7, Cambridge, MA: MIT Press, 1996.
Math Stackexchange, Is the average of primes up to n smaller than n/2, if n>19?
EXAMPLE
5 is a term since the average of the primes up to 5 is (2 + 3 + 5)/3 = 10/3, which is greater than 5/2.
8 is a term since the average of the primes up to 8 is (2 + 3 + 5 + 7)/4 = 17/4 = 4.25, which is greater than 8/2 = 4.
MAPLE
s:= proc(n) s(n):= `if`(n=0, 0, `if`(isprime(n), n, 0)+s(n-1)) end:
q:= n-> is(2*s(n)/numtheory[pi](n)>=n):
select(q, [$2..20])[]; # Alois P. Heinz, Feb 25 2022
MATHEMATICA
s[n_] := s[n] = If[n == 0, 0, If[PrimeQ[n], n, 0] + s[n-1]];
Select[Range[2, 20], 2 s[#]/PrimePi[#] > #&] (* Jean-François Alcover, Dec 26 2022, after Alois P. Heinz *)
PROG
(Python)
from sympy import primerange
def average_of_primes_up_to(i):
primes_up_to_i = list(primerange(2, i+1))
return sum(primes_up_to_i) / len(primes_up_to_i)
def a_list():
return [i for i in range(2, 20) if average_of_primes_up_to(i) >= i / 2]
CROSSREFS
KEYWORD
nonn,fini,full
AUTHOR
Masahiko Shin, Feb 25 2022
STATUS
approved