%I #28 Jun 24 2019 10:31:31
%S 0,1,2,4,26,52,1066,1667,2188,32152,67834,423176,437576,14752936,
%T 26513692,27711772,33274388,320785556,1065805109,9012701786,
%U 9256436186,12814126552,18814619428,201241053056,478999841578,670919564984,18432110906024,158312796835916,278737550525722
%N Palindromic numbers in bases 3 and 5 written in base 10.
%C 0 is only 0 regardless of the base,
%C 1 is only 1 regardless of the base,
%C 2 on the other hand is also 10 in base 2, denoted as 10_2,
%C 3 is 3 in all bases greater than 3, but is 11_2 and 10_3.
%H Giovanni Resta, <a href="/A259374/b259374.txt">Table of n, a(n) for n = 1..39</a>
%H A.H.M. Smeets, <a href="/A259374/a259374.gif">Scatterplot of log_3(number is palindromic in base 3 and base b) versus b, for b in {2,4,5, 6,7,8,10}</a>
%F Intersection of A014190 and A029952.
%e 52 is in the sequence because 52_10 = 202_5 = 1221_3.
%t (* first load nthPalindromeBase from A002113 *) palQ[n_Integer, base_Integer] := Block[{}, Reverse[ idn = IntegerDigits[n, base]] == idn]; k = 0; lst = {}; While[k < 21000000, pp = nthPalindromeBase[k, 5]; If[ palQ[pp, 3], AppendTo[lst, pp]; Print[pp]]; k++]; lst
%t b1=3; b2=5; lst={}; Do[d1=IntegerDigits[n, b1]; d2=IntegerDigits[n, b2]; If[d1==Reverse[d1]&&d2==Reverse[d2], AppendTo[lst, n]], {n, 0, 10000000}]; lst (* _Vincenzo Librandi_, Jul 15 2015 *)
%o (Python)
%o def nextpal(n,b): # returns the palindromic successor of n in base b
%o ....m, pl = n+1, 0
%o ....while m > 0:
%o ........m, pl = m//b, pl+1
%o ....if n+1 == b**pl:
%o ........pl = pl+1
%o ....n = (n//(b**(pl//2))+1)//(b**(pl%2))
%o ....m = n
%o ....while n > 0:
%o ........m, n = m*b+n%b, n//b
%o ....return m
%o n, a3, a5 = 0, 0, 0
%o while n <= 20000:
%o ....if a3 < a5:
%o ........a3 = nextpal(a3,3)
%o ....elif a5 < a3:
%o ........a5 = nextpal(a5,5)
%o ....else: # a3 == a5
%o ........print(n,a3)
%o ........a3, a5, n = nextpal(a3,3), nextpal(a5,5), n+1
%o # _A.H.M. Smeets_, Jun 03 2019
%Y Cf. A048268, A060792, A097856, A097928, A182232, A259374, A097929, A182233, A259375, A259376, A097930, A182234, A259377, A259378, A249156, A097931, A259380-A259384, A099145, A259385-A259390, A099146, A007632, A007633, A029961-A029964, A029804, A029965-A029970, A029731, A097855, A250408-A250411, A099165, A250412.
%K nonn,base
%O 1,3
%A Eric A. Schmidt and _Robert G. Wilson v_, Jul 14 2015