login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A071704 Number of ways to represent the n-th prime as arithmetic mean of three other odd primes. 4

%I #20 Mar 09 2019 07:22:55

%S 0,0,0,2,5,7,10,14,16,24,29,31,42,40,43,52,62,70,75,87,82,96,102,112,

%T 127,137,136,142,154,154,186,199,204,215,233,248,250,262,272,284,309,

%U 324,344,334,348,358,406,414,430,446,441,489,486,511,508

%N Number of ways to represent the n-th prime as arithmetic mean of three other odd primes.

%H Robert Israel, <a href="/A071704/b071704.txt">Table of n, a(n) for n = 1..2000</a>

%e a(5)=5 as A000040(5)=11 and there are no more representations not containing 11 than 11 = (3+7+23)/3 = (3+13+17)/3 = (5+5+23)/3 = (7+7+19)/3 = (7+13+13)/3.

%p N:= 300: # to get the first A000720(N) terms

%p P:= select(isprime, [seq(i,i=3..3*N,2)]):

%p nP:= nops(P):

%p V:= Vector(N):

%p for i from 1 to nP do

%p for j from i to nP do

%p for k from j to nP while P[i]+P[j]+P[k] <= 3*N do

%p r:= (P[i]+P[j]+P[k])/3;

%p if r::integer and isprime(r) and r <> P[j] and r <= N then V[r]:= V[r]+1 fi

%p od od od:

%p seq(V[ithprime(i)],i=1..numtheory:-pi(N)); # _Robert Israel_, Aug 09 2018

%t M = 300; (* to get the first A000720(M) *)

%t P = Select[Range[3, 3*M, 2], PrimeQ]; nP = Length[P]; V = Table[0, {M}];

%t For[i = 1, i <= nP, i++,

%t For[j = i, j <= nP, j++,

%t For[k = j, k <= nP && P[[i]] + P[[j]] + P[[k]] <= 3*M , k++, r = (P[[i]] + P[[j]] + P[[k]])/3; If[IntegerQ[r] && PrimeQ[r] && r != P[[j]] && r <= M, V[[r]] = V[[r]]+1]

%t ]]];

%t Table[V[[Prime[i]]], {i, 1, PrimePi[M]}] (* _Jean-François Alcover_, Mar 09 2019, after _Robert Israel_ *)

%o (Haskell)

%o a071704 n = z (us ++ vs) 0 (3 * q) where

%o z _ 3 m = fromEnum (m == 0)

%o z ps'@(p:ps) i m = if m < p then 0 else z ps' (i+1) (m - p) + z ps i m

%o (us, _:vs) = span (< q) a065091_list; q = a000040 n

%o -- _Reinhard Zumkeller_, May 24 2015

%o (PARI) a(n, p=prime(n))=my(s=0); forprime(q=p+2, 3*p-4, my(t=3*p-q); forprime(r=max(t-q, 3), (3*p-q)\2, if(t!=p+r && isprime(t-r), s++))); s \\ _Charles R Greathouse IV_, Jun 04 2015

%Y Cf. A071681, A071703, A000040, A065091, A258233.

%K nonn

%O 1,4

%A _Reinhard Zumkeller_, Jun 03 2002

%E Definition corrected by _Zak Seidov_, May 24 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 00:30 EDT 2024. Contains 371917 sequences. (Running on oeis4.)