login
Palindromes such that additive and multiplicative persistences coincide.
2

%I #11 Jun 22 2023 14:59:10

%S 0,1,2,3,4,5,6,7,8,9,11,22,33,99,101,111,121,131,141,151,161,171,202,

%T 212,222,262,282,303,313,393,404,424,454,474,525,545,565,585,595,636,

%U 656,676,757,838,858,959,1001,1111,1221,1331,1441,1991,2002,2112,2552

%N Palindromes such that additive and multiplicative persistences coincide.

%C Palindromes k for which A031286(k) = A031346(k).

%H Michael S. Branicky, <a href="/A239480/b239480.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/AdditivePersistence.html">Additive Persistence</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/MultiplicativePersistence.html">Multiplicative Persistence</a>

%H <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>

%F A002113 INTERSECT A239427.

%e 99 -> 18 -> 9 has additive persistence 2. 99 -> 81 -> 8 has multiplicative persistence 2. The palindromic number 99 is therefore in the sequence.

%o (PARI) for(n=0, 2552, s=Vec(Str(n)); if(s==vecextract(s, "-1..1"), v=n; a=0; while(n>9, a++; n=sumdigits(n)); n=v; m=0; while(n>9, m++; d=digits(n); n=prod(k=1, #d, d[k])); n=v; if(a==m, print1(n, ", "))));

%o (Python)

%o from math import prod

%o from itertools import count, islice, product

%o def A031286(n):

%o ap = 0

%o while n > 9: n, ap = sum(map(int, str(n))), ap+1

%o return ap

%o def A031346(n):

%o mp = 0

%o while n > 9: n, mp = prod(map(int, str(n))), mp+1

%o return mp

%o def is_pal(n): return (s:=str(n)) == s[::-1]

%o def pals(base=10): # all d-digit palindromes

%o digits = "".join(str(i) for i in range(base))

%o for d in count(1):

%o for p in product(digits, repeat=d//2):

%o if d > 1 and p[0] == "0": continue

%o left = "".join(p); right = left[::-1]

%o for mid in [[""], digits][d%2]: yield int(left + mid + right)

%o def ok(n): return is_pal(n) and A031286(n) == A031346(n)

%o def agen(): yield from filter(ok, pals())

%o print(list(islice(agen(), 20))) # _Michael S. Branicky_, Jun 22 2023

%Y Cf. A002113, A031286, A031346, A239427.

%K nonn,base

%O 1,3

%A _Arkadiusz Wesolowski_, Mar 20 2014