login
Nonprime palindromes n with only the digits 0, 1, 2 such that the product of divisors of n is also a palindrome.
1

%I #19 Feb 03 2020 10:56:33

%S 1,22,111,121,202,1001,1111,10001,10201,11111,100001,1000001,1001001,

%T 1012101,1100011,1101011,1111111,10000001,100000001,101000101,

%U 110000011,200010002,10000000001,10011111001,11000100011,11001010011,11100100111,11101010111,20000100002

%N Nonprime palindromes n with only the digits 0, 1, 2 such that the product of divisors of n is also a palindrome.

%C A subsequence of A244423.

%H Chai Wah Wu, <a href="/A261534/b261534.txt">Table of n, a(n) for n = 1..203</a>

%t lim = 1000000; palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d]; c = Complement[Range@ lim, Prime@ Range@ PrimePi@ lim]; t = Select[c, Total@ Take[RotateRight@ DigitCount@ #, -7] == 0 &]; Select[t, palQ[Times @@ Divisors@ #] &] (* _Michael De Vlieger_, Sep 02 2015 *)

%t Rest[Select[FromDigits/@Tuples[{0,1,2},11],!PrimeQ[#]&&AllTrue[{#,Times@@ Divisors[ #]},PalindromeQ]&]] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Feb 02 2020 *)

%o (Python)

%o from __future__ import division

%o from sympy import divisor_count

%o from gmpy2 import isqrt, t_divmod, digits

%o def palgen(l,b=10): # generator of palindromes in base b of length <= 2*l

%o if l > 0:

%o yield 0

%o for x in range(1,l+1):

%o n = b**(x-1)

%o n2 = n*b

%o for y in range(n,n2):

%o k, m = y//b, 0

%o while k >= b:

%o k, r = t_divmod(k,b)

%o m = b*m + r

%o yield y*n + b*m + k

%o for y in range(n,n2):

%o k, m = y, 0

%o while k >= b:

%o k, r = t_divmod(k,b)

%o m = b*m + r

%o yield y*n2 + b*m + k

%o A261534_list = [1]

%o for m in palgen(17,3):

%o n = int(digits(m,3))

%o d = int(divisor_count(n))

%o if d > 2:

%o q, r = t_divmod(d,2)

%o s = digits(n**q*(isqrt(n) if r else 1))

%o if s == s[::-1]:

%o A261534_list.append(n)

%Y Cf. A244411, A244423.

%K nonn,base

%O 1,2

%A _Chai Wah Wu_, Aug 31 2015