login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A336815
Number of subsets of {1..n} whose sum of squares of elements is a square.
2
1, 2, 3, 4, 6, 7, 10, 12, 17, 26, 37, 69, 120, 233, 417, 781, 1386, 2561, 4638, 8387, 15495, 27709, 51580, 94054, 176266, 330004, 618846, 1174439, 2216002, 4232301, 8041866, 15344759, 29258898, 55850376, 106792759, 204203789, 391147474, 749434144, 1439261966
OFFSET
0,2
FORMULA
a(n) = 1 + Sum_{k=1..n} A339612(k).
EXAMPLE
a(8) = 17 subsets: {}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {3, 4}, {6, 8}, {1, 4, 8}, {2, 3, 6}, {2, 4, 5, 6}, {1, 2, 4, 6, 8}, {1, 3, 4, 5, 7} and {2, 4, 6, 7, 8}.
PROG
(Python)
from sympy.ntheory.primetest import is_square
from functools import lru_cache
@lru_cache(maxsize=None)
def b(n, sos, c):
if n == 0:
if is_square(sos): return 1
return 0
return b(n-1, sos, c) + b(n-1, sos+n*n, c+1)
a = lambda n: b(n, 0, 0)
print([a(n) for n in range(40)]) # Michael S. Branicky, Dec 10 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Ilya Gutkovskiy, Dec 09 2020
EXTENSIONS
a(24)-a(38) from Michael S. Branicky, Dec 09 2020
STATUS
approved