login
Numbers m such that the average of the prime numbers up to m is greater than or equal to m/2.
0

%I #48 Dec 26 2022 11:38:24

%S 2,3,4,5,6,7,8,11,13,19

%N Numbers m such that the average of the prime numbers up to m is greater than or equal to m/2.

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

%H Hassani Mehdi, <a href="https://vuir.vu.edu.au/18085/">A Refinement of Mandl's Inequality</a>, report collection, 8 (2) (2005).

%H Eric Bach and Jefrey Shallit, <a href="https://www.amazon.com/exec/obidos/ISBN%3D0262024055/ericstreasuretroA/"> Algorithmic Number Theory, Vol. 1: Efficient Algorithms</a>, Section 2.7, Cambridge, MA: MIT Press, 1996.

%H Math Stackexchange, <a href="https://math.stackexchange.com/questions/4391776/is-the-average-of-primes-up-to-n-smaller-than-fracn2-if-n-19">Is the average of primes up to n smaller than n/2, if n>19?</a>

%F 2*A034387(a(n))/A000720(a(n)) >= a(n).

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

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

%p s:= proc(n) s(n):= `if`(n=0, 0, `if`(isprime(n), n, 0)+s(n-1)) end:

%p q:= n-> is(2*s(n)/numtheory[pi](n)>=n):

%p select(q, [$2..20])[]; # _Alois P. Heinz_, Feb 25 2022

%t s[n_] := s[n] = If[n == 0, 0, If[PrimeQ[n], n, 0] + s[n-1]];

%t Select[Range[2, 20], 2 s[#]/PrimePi[#] > #&] (* _Jean-François Alcover_, Dec 26 2022, after _Alois P. Heinz_ *)

%o (Python)

%o from sympy import primerange

%o def average_of_primes_up_to(i):

%o primes_up_to_i = list(primerange(2, i+1))

%o return sum(primes_up_to_i) / len(primes_up_to_i)

%o def a_list():

%o return [i for i in range(2, 20) if average_of_primes_up_to(i) >= i / 2]

%Y Cf. A000040, A000720, A034387.

%K nonn,fini,full

%O 1,1

%A _Masahiko Shin_, Feb 25 2022