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!)
A309160 Number of nonempty subsets of [n] whose elements have a prime average. 6

%I #18 Sep 25 2022 10:50:06

%S 0,1,4,6,11,15,22,40,72,118,199,355,604,920,1306,1906,3281,6985,16446,

%T 38034,82490,168076,325935,604213,1068941,1815745,3038319,5246725,

%U 9796132,19966752,42918987,92984247,197027405,402932711,792381923,1499918753,2746078246

%N Number of nonempty subsets of [n] whose elements have a prime average.

%H Alois P. Heinz, <a href="/A309160/b309160.txt">Table of n, a(n) for n = 1..200</a>

%F a(n) < A051293(n).

%e a(3) = 4 because 4 of the subsets of [3], namely {2}, {3}, {1,3}, {1,2,3}, have prime averages.

%p b:= proc(n, s, c) option remember; `if`(n=0,

%p `if`(c>0 and denom(s)=1 and isprime(s), 1, 0),

%p b(n-1, s, c)+b(n-1, (s*c+n)/(c+1), c+1))

%p end:

%p a:= n-> b(n, 0$2):

%p seq(a(n), n=1..40); # _Alois P. Heinz_, Jul 15 2019

%t a[n_]:=Length[Select[Subsets[Range[n]],PrimeQ[Mean[#]]&]]; a/@Range[25]

%o (Python)

%o from sympy import isprime

%o from functools import lru_cache

%o def cond(s, c): q, r = divmod(s, c); return r == 0 and isprime(q)

%o @lru_cache(maxsize=None)

%o def b(n, s, c):

%o if n == 0: return int (c > 0 and cond(s, c))

%o return b(n-1, s, c) + b(n-1, s+n, c+1)

%o a = lambda n: b(n, 0, 0)

%o print([a(n) for n in range(1, 41)]) # _Michael S. Branicky_, Sep 25 2022

%Y Cf. A051293, A114976, A127542.

%K nonn

%O 1,3

%A _Ivan N. Ianakiev_, Jul 15 2019

%E a(26)-a(37) from _Alois P. Heinz_, Jul 15 2019

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 August 11 23:45 EDT 2024. Contains 375082 sequences. (Running on oeis4.)