OFFSET
1,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..200
FORMULA
a(n) < A051293(n).
EXAMPLE
a(3) = 4 because 4 of the subsets of [3], namely {2}, {3}, {1,3}, {1,2,3}, have prime averages.
MAPLE
b:= proc(n, s, c) option remember; `if`(n=0,
`if`(c>0 and denom(s)=1 and isprime(s), 1, 0),
b(n-1, s, c)+b(n-1, (s*c+n)/(c+1), c+1))
end:
a:= n-> b(n, 0$2):
seq(a(n), n=1..40); # Alois P. Heinz, Jul 15 2019
MATHEMATICA
a[n_]:=Length[Select[Subsets[Range[n]], PrimeQ[Mean[#]]&]]; a/@Range[25]
PROG
(Python)
from sympy import isprime
from functools import lru_cache
def cond(s, c): q, r = divmod(s, c); return r == 0 and isprime(q)
@lru_cache(maxsize=None)
def b(n, s, c):
if n == 0: return int (c > 0 and cond(s, c))
return b(n-1, s, c) + b(n-1, s+n, c+1)
a = lambda n: b(n, 0, 0)
print([a(n) for n in range(1, 41)]) # Michael S. Branicky, Sep 25 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Ivan N. Ianakiev, Jul 15 2019
EXTENSIONS
a(26)-a(37) from Alois P. Heinz, Jul 15 2019
STATUS
approved