OFFSET
1,2
COMMENTS
If a term has a decimal digit that is odd, it must have an odd number of decimal digits and all odd digits are the same. - Chai Wah Wu, Jul 29 2022
If a term has an even number of decimal digits, then it must have only even decimal digits. - Bernard Schott, Jul 30 2022
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
474 is palindrome and 474 has two 4's and one 7 in its decimal expansion, hence 474 is a term.
MATHEMATICA
simQ[n_] := AllTrue[Tally @ IntegerDigits[n], EvenQ[Plus @@ #] &]; Select[Range[10^4], PalindromeQ[#] && simQ[#] &] (* Amiram Eldar, Jul 28 2022 *)
PROG
(Python)
from itertools import count, islice, product
def simb(n): s = str(n); return all(s.count(d)%2==int(d)%2 for d in set(s))
def pals(): # generator of palindromes
digits = "0123456789"
for d in count(1):
for p in product(digits, repeat=d//2):
if d > 1 and p[0] == "0": continue
left = "".join(p); right = left[::-1]
for mid in [[""], digits][d%2]:
yield int(left + mid + right)
def agen(): yield from filter(simb, pals())
print(list(islice(agen(), 55))) # Michael S. Branicky, Jul 28 2022
(Python) # faster version based on Comments
from itertools import count, islice, product
def odgen(d): yield from [1, 3, 5, 7, 9] if d == 1 else sorted(int(f+"".join(p)+o+"".join(p[::-1])+f) for o in "13579" for f in o + "2468" for p in product(o+"02468", repeat=d//2-1))
def evgen(d): yield from (int(f+"".join(p)+"".join(p[::-1])+f) for f in "2468" for p in product("02468", repeat=d//2-1))
def A356177gen():
for d in count(1, step=2): yield from odgen(d); yield from evgen(d+1)
print(list(islice(A356177gen(), 55))) # Michael S. Branicky, Jul 30 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bernard Schott, Jul 28 2022
STATUS
approved