A357356 Number of nonempty subsets of {1..n} whose elements have an even average.
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
Keywords
Examples
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}.
Programs
-
Python
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
Formula
Extensions
a(24)-a(37) from Michael S. Branicky, Sep 25 2022