login
Palindromes in base 10 that are also palindromes in base 60.
3

%I #24 Sep 08 2022 08:46:13

%S 0,1,2,3,4,5,6,7,8,9,11,22,33,44,55,55155,55455,55755,57075,57375,

%T 113311,148841,2796972,8372738,11166111,14033041,26233262,28933982,

%U 150050051,151141151,152070251,152232251,153161351,153323351,154252451,154414451,155343551,155505551

%N Palindromes in base 10 that are also palindromes in base 60.

%H Chai Wah Wu, <a href="/A262069/b262069.txt">Table of n, a(n) for n = 1..82</a>

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

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

%H Wikipedia, <a href="http://www.wikipedia.org/wiki/Palindromic_number">Palindromic number</a>

%H Wikipedia, <a href="http://www.wikipedia.org/wiki/Sexagesimal">Sexagesimal</a>

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

%e n = 22: 41*60^2 + 20*60^1 + 41*60^0 = A262065(2541) = A002113(1148) = 148841 = a(22);

%e n = 27: 2*60^4 + 1*60^3 + 27*60^2 + 1*60^1 + 2*60^0 = A262065(7348) = A002113(12623) = 26233262 = a(27).

%t palQ[n_Integer, base_Integer]:=Module[{idn=IntegerDigits[n, base]}, idn==Reverse[idn]]; Select[Range[10^6], palQ[#, 10]&& palQ[#, 60] &] (* _Vincenzo Librandi_, Sep 11 2015 *)

%o (Haskell)

%o -- import Data.List.Ordered (isect)

%o a262069 n = a262069_list !! (n-1)

%o a262069_list = isect a002113_list a262065_list

%o (Python)

%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 = 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 = divmod(k,b)

%o m = b*m + r

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

%o A262069_list = [n for n in palgen(5,60) if str(n) == str(n)[::-1]] # _Chai Wah Wu_, Sep 10 2015

%o (Magma) [n: n in [0..2*10^7] | Intseq(n, 60) eq Reverse(Intseq(n, 60)) and Intseq(n, 10) eq Reverse(Intseq(n, 10))]; // _Vincenzo Librandi_, Sep 11 2015

%o (PARI) ispal(v) = v == Vecrev(v);

%o isok(n) = ispal(digits(n)) && ispal(digits(n,60)); \\ _Michel Marcus_, Sep 11 2015

%Y Intersection of A002113 and A262065.

%K nonn,base

%O 1,3

%A _Reinhard Zumkeller_, Sep 10 2015

%E More terms from _Chai Wah Wu_, Sep 10 2015