cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A339484 Number of subsets of {1..n} whose cardinality is equal to the average of the elements.

This page as a plain text file.
%I A339484 #25 Feb 16 2025 08:34:01
%S A339484 1,1,2,3,4,7,11,17,28,47,80,139,245,436,784,1419,2585,4738,8729,16154,
%T A339484 30015,55966,104682,196378,369384,696494,1316252,2492683,4729673,
%U A339484 8990374,17118020,32644544,62345875,119235519,228333179,437790086,840362539,1614894770,3106516468
%N A339484 Number of subsets of {1..n} whose cardinality is equal to the average of the elements.
%H A339484 Alois P. Heinz, <a href="/A339484/b339484.txt">Table of n, a(n) for n = 1..300</a>
%H A339484 Eric W. Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/ArithmeticMean.html">Arithmetic Mean</a>
%e A339484 a(6) = 7 subsets: {1}, {1, 3}, {1, 2, 6}, {1, 3, 5}, {2, 3, 4}, {1, 4, 5, 6} and {2, 3, 5, 6}.
%o A339484 (Python)
%o A339484 from itertools import combinations
%o A339484 def a(n):
%o A339484     ss, s = 0, range(1, n+1)
%o A339484     for r in range(1, n+1):
%o A339484         rr = r*r
%o A339484         ss += sum(sum(subs)==rr for subs in combinations(s, r))
%o A339484     return ss
%o A339484 print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Dec 06 2020
%o A339484 (Python)
%o A339484 from functools import lru_cache
%o A339484 from itertools import combinations
%o A339484 @lru_cache(maxsize=None)
%o A339484 def A339484(n):
%o A339484     return 1 if n == 1 else A339484(n-1)+sum(sum(d)+n==(i+1)**2 for i in range(1,n) for d in combinations(range(1,n),i)) # _Chai Wah Wu_, Dec 07 2020
%o A339484 (Python)
%o A339484 from functools import lru_cache
%o A339484 @lru_cache(maxsize=None)
%o A339484 def b(n, s, c):
%o A339484     if n == 0: return c and int(s == c*c)
%o A339484     return b(n-1, s, c) + b(n-1, s+n, c+1)
%o A339484 a = lambda n: b(n, 0, 0)
%o A339484 print([a(n) for n in range(1, 101)]) # _Michael S. Branicky_, Oct 06 2022
%Y A339484 Cf. A051293, A126024.
%K A339484 nonn
%O A339484 1,3
%A A339484 _Ilya Gutkovskiy_, Dec 06 2020
%E A339484 a(24)-a(32) from _Michael S. Branicky_, Dec 06 2020
%E A339484 a(33)-a(35) from _Chai Wah Wu_, Dec 07 2020
%E A339484 a(36)-a(39) from _Michael S. Branicky_, Dec 08 2020