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