login
Palindromes whose perfect deficiency (A109883) is also palindromic.
1

%I #17 Apr 01 2024 10:05:46

%S 1,2,3,4,5,6,7,8,9,22,44,222,292,414,646,717,848,979,27072,28882,

%T 45954,74247,90109,96569,118811,2376732,5136315,5185815,5266625,

%U 5635365,5684865,6344436,7424247,7481847,7484847,7929297,9858589,12333321,21922912,32255223

%N Palindromes whose perfect deficiency (A109883) is also palindromic.

%H Michael S. Branicky, <a href="/A110002/b110002.txt">Table of n, a(n) for n = 1..101</a> (all terms < 10^14)

%t subtract = If[ #1 < #2, Throw[ #1], #1 - #2]&;d[n_] := Catch @ Fold[subtract, n, Divisors @ n];Select[Range[10000000],PalindromeQ[#]&&PalindromeQ[d[#]]&] (* _James C. McMahon_, Mar 31 2024 *)

%o (Python) # uses imports, function in A109883

%o from itertools import count, islice, product

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

%o def pals(): # generator of palindromes

%o digits = "0123456789"

%o yield from map(int, digits)

%o for d in count(2):

%o for f in "123456789":

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

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

%o for mid in [[""], digits][d%2]:

%o yield int(left + mid + right)

%o def agen(): yield from (p for p in pals() if p>0 and ispal(A109883(p)))

%o print(list(islice(agen(), 40))) # _Michael S. Branicky_, Mar 31 2024

%Y Cf. A002113, A109883.

%K base,nonn

%O 1,2

%A _Jason Earls_, Sep 02 2005

%E a(38) and beyond from _Michael S. Branicky_, Mar 31 2024