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.

Showing 1-2 of 2 results.

A339508 Number of subsets of {2..n} such that the product of the elements is a decimal palindrome.

Original entry on oeis.org

1, 1, 2, 4, 6, 7, 8, 10, 11, 13, 13, 33, 43, 56, 70, 73, 99, 114, 134, 151, 151, 185, 333, 372, 445, 456, 558, 565, 672, 1031, 1031, 1220, 1518, 1967, 2161, 2176, 2238, 5399, 5543, 6720, 6720, 8857, 10019, 11819, 16882, 16896, 18072, 19299, 21267, 23405, 23405, 24686
Offset: 0

Views

Author

Ilya Gutkovskiy, Dec 07 2020

Keywords

Comments

a(k*10) = a(k*10-1) because all new products end in 0, thus not palindromes. - Michael S. Branicky, Dec 08 2020

Examples

			a(9) = 13 subsets: {}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {2, 3}, {2, 4}, {4, 7, 9} and {2, 3, 6, 7}.
		

Crossrefs

Programs

  • Python
    from numpy import prod
    from itertools import combinations
    def a(n):
        ans = 1  # empty set
        for r in range(1, n):
            for s in combinations(range(2, n+1), r):
                strsp = str(prod(s))
                ans += strsp==strsp[::-1]
        return ans
    print([a(n) for n in range(20)])  # Michael S. Branicky, Dec 08 2020
    
  • Python
    from functools import lru_cache, reduce
    from operator import mul
    from itertools import combinations
    @lru_cache(maxsize=None)
    def A339508(n):
        nlist = [i for i in range(2,n) if i % 10 != 0]
        if n == 0 or n == 1:
            return 1
        c = A339508(n-1)
        if n % 10 != 0:
            if str(n) == str(n)[::-1]:
                c += 1
            for i in range(1,len(nlist)+1):
                for d in combinations(nlist,i):
                    s = str(reduce(mul,d)*n)
                    if s == s[::-1]:
                        c += 1
        return c # Chai Wah Wu, Dec 08 2020
    
  • Python
    from functools import lru_cache
    def cond(p): sp = str(p); return sp == sp[::-1]
    @lru_cache(maxsize=None)
    def b(n, p):
        if n == 1: return int(cond(p))
        return b(n-1, p) + b(n-1, p*n) if p*n%10 else b(n-1, p)
    def a(n): return 1 if n < 2 else b(n, 1)
    print([a(n) for n in range(36)]) # Michael S. Branicky, Oct 05 2022

Extensions

a(23)-a(32) from Michael S. Branicky, Dec 08 2020
a(33)-a(42) from Chai Wah Wu, Dec 08 2020
a(43)-a(48) from Chai Wah Wu, Dec 11 2020
a(49)-a(51) from Michael S. Branicky, Oct 05 2022

A377122 Number of subsets of the first n nonzero decimal palindromes whose sum is a nonzero decimal palindrome.

Original entry on oeis.org

1, 3, 7, 14, 23, 31, 40, 54, 78, 125, 219, 416, 865, 1719, 3375, 6646, 13139, 26103, 52029, 103989, 207805, 415509, 828997, 1629345, 3084165, 5525120, 9319815, 14896533, 22847075, 34326110, 51747646, 80304059, 130836329, 225170322, 406349931, 759326388, 1453773251
Offset: 1

Views

Author

Ilya Gutkovskiy, Oct 17 2024

Keywords

Examples

			a(5) = 23 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}.
		

Crossrefs

Programs

  • Python
    from functools import cache
    def cond(s): return s > 0 and (w:=str(s)) == w[::-1]
    def u(n): return A002113(n+1) # uses function in A002113
    @cache
    def b(n, s):
        if n == 0: return int(cond(s))
        return b(n-1, s) + b(n-1, s+u(n))
    a = lambda n: b(n, 0)
    print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Oct 18 2024

Extensions

a(23) and beyond from Michael S. Branicky, Oct 18 2024
Showing 1-2 of 2 results.