A357355
Number of nonempty subsets of {1..n} whose elements have an odd average.
Original entry on oeis.org
1, 1, 2, 4, 9, 13, 20, 38, 71, 119, 206, 384, 713, 1285, 2356, 4428, 8331, 15569, 29270, 55582, 105717, 200847, 382808, 732744, 1404667, 2694391, 5178186, 9973416, 19233457, 37125547, 71754692, 138871244, 269038123, 521666967, 1012485750, 1966957674, 3824314685
Offset: 1
a(6) = 13 subsets: {1}, {3}, {5}, {1, 5}, {2, 4}, {4, 6}, {1, 2, 6}, {1, 3, 5}, {2, 3, 4}, {4, 5, 6}, {1, 2, 3, 6}, {1, 2, 4, 5} and {1, 2, 3, 4, 5}.
-
from functools import lru_cache
def cond(s, c): q, r = divmod(s, c); return r == 0 and q&1
@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, 51)]) # Michael S. Branicky, Sep 25 2022
A357356
Number of nonempty subsets of {1..n} whose elements have an even average.
Original entry on oeis.org
0, 1, 3, 4, 6, 13, 25, 38, 64, 119, 219, 384, 686, 1285, 2405, 4428, 8236, 15569, 29463, 55582, 105326, 200847, 383609, 732744, 1403004, 2694391, 5181663, 9973416, 19226166, 37125547, 71770069, 138871244, 269005540, 521666967, 1012555015, 1966957674, 3824166974
Offset: 1
a(6) = 13 subsets: {2}, {4}, {6}, {1, 3}, {2, 6}, {3, 5}, {1, 2, 3}, {1, 5, 6}, {2, 4, 6}, {3, 4, 5}, {1, 4, 5, 6}, {2, 3, 5, 6} and {2, 3, 4, 5, 6}.
-
from functools import lru_cache
def cond(s, c): q, r = divmod(s, c); return r == 0 and q&1 == 0
@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, 51)]) # Michael S. Branicky, Sep 25 2022
A339485
Number of subsets of the first n primes whose elements have a prime average.
Original entry on oeis.org
1, 2, 3, 6, 9, 12, 17, 30, 51, 88, 149, 264, 439, 746, 1261, 2234, 4211, 7996, 14899, 28048, 54037, 106442, 208625, 398588, 735365, 1331590, 2421573, 4481896, 8504953, 16497150, 32595915, 64614636, 127968263, 252470776, 495388085, 962475122, 1847742473, 3504948056
Offset: 1
a(5) = 9 subsets: {2}, {3}, {5}, {7}, {11}, {3, 7}, {3, 11}, {3, 5, 7} and {3, 7, 11}.
-
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+ithprime(n))/(c+1), c+1))
end:
a:= n-> b(n, 0$2):
seq(a(n), n=1..40); # Alois P. Heinz, Dec 08 2020
-
b[n_, s_, c_] := b[n, s, c] = If[n == 0,
If[c > 0 && Denominator[s] == 1 && PrimeQ[s], 1, 0],
b[n-1, s, c] + b[n-1, (s*c + Prime[n])/(c+1), c+1]];
a[n_] := b[n, 0, 0];
Array[a, 40] (* Jean-François Alcover, Jul 09 2021, after Alois P. Heinz *)
-
from sympy import prime, isprime
from itertools import chain, combinations
def powerset(s): # skip empty set and singletons
return chain.from_iterable(combinations(s, r) for r in range(2,len(s)+1))
def a(n):
out = n # count all singletons
for s in powerset([prime(i) for i in range(1, n+1)]):
ss = sum(s)
if ss%len(s) == 0:
if isprime(ss//len(s)): out += 1
return out
print([a(n) for n in range(1, 21)]) # Michael S. Branicky, Dec 06 2020
-
from itertools import combinations
from sympy import prime
def A339485(n):
c, primeset2 = n, set(prime(i) for i in range(1,n))
primeset = primeset2 | {prime(n)}
for l in range(2,n+1):
for d in combinations(primeset,l):
a, b = divmod(sum(d),l)
if b == 0 and a in primeset2:
c += 1
return c # Chai Wah Wu, Dec 07 2020
-
from functools import lru_cache
from sympy import sieve, isprime
@lru_cache(maxsize=None)
def b(n, s, c):
if n == 0: return int(c and s%c == 0 and isprime(s//c))
return b(n-1, s, c) + b(n-1, s+sieve[n], c+1)
a = lambda n: b(n, 0, 0)
print([a(n) for n in range(1, 41)]) # Michael S. Branicky, Oct 06 2022
A369391
Number of nonempty subsets of {1..n} whose elements have a square average.
Original entry on oeis.org
1, 1, 1, 2, 4, 10, 20, 26, 31, 35, 41, 63, 143, 399, 1083, 2554, 5078, 8596, 12772, 17222, 21792, 27126, 36538, 62530, 146701, 412191, 1178071, 3156949, 7703823, 16992539, 33946851, 61840501, 103674983, 161604395, 236759149, 330078718, 446073360, 606337592
Offset: 1
a(5) = 4 subsets: {1}, {4}, {3, 5} and {3, 4, 5}.
A339556
Number of subsets of the first n primes whose elements have a prime root-mean-square.
Original entry on oeis.org
1, 2, 3, 4, 5, 6, 11, 16, 19, 30, 41, 54, 69, 106, 177, 272, 397, 686, 1299, 2416, 4225, 7196, 11701, 20352, 36305, 70134, 132721, 248722, 473391, 894318, 1674923, 3054022, 5452067, 9626552, 16696543, 29086462, 51830095, 96887612, 192393735, 397875694
Offset: 1
a(7) = 11 subsets: {2}, {3}, {5}, {7}, {11}, {13}, {17}, {7, 17}, {5, 7, 17}, {7, 13, 17} and {5, 7, 11, 17}.
Showing 1-5 of 5 results.