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.

A339507 Number of subsets of {1..n} whose sum is a decimal palindrome.

This page as a plain text file.
%I A339507 #34 Feb 16 2025 08:34:01
%S A339507 1,2,4,8,15,24,32,41,55,79,126,220,406,778,1524,3057,6310,13211,27500,
%T A339507 56246,113003,224220,442106,870323,1715503,3391092,6726084,13382357,
%U A339507 26686192,53286329,106469764,212803832,425434124,850676115,1701169724,3402169203,6804150711,13608072837,27215890383,54431527170
%N A339507 Number of subsets of {1..n} whose sum is a decimal palindrome.
%H A339507 Michael S. Branicky, <a href="/A339507/b339507.txt">Table of n, a(n) for n = 0..1000</a>
%H A339507 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PalindromicNumber.html">Palindromic Number</a>
%H A339507 <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>
%e A339507 a(5) = 24 subsets: {}, {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5}, {1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {2, 3, 4}, {2, 4, 5} and {1, 2, 3, 5}.
%o A339507 (Python)
%o A339507 from itertools import combinations
%o A339507 def a(n):
%o A339507     ans = 0
%o A339507     for r in range(n+1):
%o A339507         for s in combinations(range(1,n+1),r):
%o A339507             strss = str(sum(s))
%o A339507             ans += strss==strss[::-1]
%o A339507     return ans
%o A339507 print([a(n) for n in range(21)]) # _Michael S. Branicky_, Dec 07 2020
%o A339507 (Python)
%o A339507 from functools import lru_cache
%o A339507 from itertools import combinations
%o A339507 @lru_cache(maxsize=None)
%o A339507 def A339507(n):
%o A339507     pallist = set(i for i in range(1,n*(n+1)//2+1) if str(i) == str(i)[::-1])
%o A339507     return 1 if n == 0 else A339507(n-1) + sum(sum(d)+n in pallist for i in range(n) for d in combinations(range(1,n),i)) # _Chai Wah Wu_, Dec 08 2020
%o A339507 (Python)
%o A339507 from functools import lru_cache
%o A339507 def cond(s): ss = str(s); return ss == ss[::-1]
%o A339507 @lru_cache(maxsize=None)
%o A339507 def b(n, s):
%o A339507     if n == 0: return int(cond(s))
%o A339507     return b(n-1, s) + b(n-1, s+n)
%o A339507 a = lambda n: b(n, 0)
%o A339507 print([a(n) for n in range(100)]) # _Michael S. Branicky_, Oct 05 2022
%Y A339507 Cf. A002113, A126024, A126111, A127542, A284250, A339508.
%K A339507 nonn,base
%O A339507 0,2
%A A339507 _Ilya Gutkovskiy_, Dec 07 2020
%E A339507 a(23)-a(36) from _Michael S. Branicky_, Dec 08 2020
%E A339507 a(37)-a(39) from _Chai Wah Wu_, Dec 11 2020