login
Number of nonempty subsets of {1..n} whose elements have an odd average.
5

%I #12 Sep 25 2022 11:03:55

%S 1,1,2,4,9,13,20,38,71,119,206,384,713,1285,2356,4428,8331,15569,

%T 29270,55582,105717,200847,382808,732744,1404667,2694391,5178186,

%U 9973416,19233457,37125547,71754692,138871244,269038123,521666967,1012485750,1966957674,3824314685

%N Number of nonempty subsets of {1..n} whose elements have an odd average.

%F a(n) = A051293(n) - A357356(n). - _Michael S. Branicky_, Sep 25 2022

%e 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}.

%o (Python)

%o from functools import lru_cache

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

%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, 51)]) # _Michael S. Branicky_, Sep 25 2022

%Y Cf. A051293, A309160, A357356.

%K nonn

%O 1,3

%A _Ilya Gutkovskiy_, Sep 25 2022

%E a(24)-a(37) from _Michael S. Branicky_, Sep 25 2022