A259374 Palindromic numbers in bases 3 and 5 written in base 10.
0, 1, 2, 4, 26, 52, 1066, 1667, 2188, 32152, 67834, 423176, 437576, 14752936, 26513692, 27711772, 33274388, 320785556, 1065805109, 9012701786, 9256436186, 12814126552, 18814619428, 201241053056, 478999841578, 670919564984, 18432110906024, 158312796835916, 278737550525722
Offset: 1
Examples
52 is in the sequence because 52_10 = 202_5 = 1221_3.
Links
Crossrefs
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.
Programs
-
Mathematica
(* 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 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 *)
-
Python
def nextpal(n,b): # returns the palindromic successor of n in base b m, pl = n+1, 0 while m > 0: m, pl = m//b, pl+1 if n+1 == b**pl: pl = pl+1 n = (n//(b**(pl//2))+1)//(b**(pl%2)) m = n while n > 0: m, n = m*b+n%b, n//b return m n, a3, a5 = 0, 0, 0 while n <= 20000: if a3 < a5: a3 = nextpal(a3,3) elif a5 < a3: a5 = nextpal(a5,5) else: # a3 == a5 print(n,a3) a3, a5, n = nextpal(a3,3), nextpal(a5,5), n+1 # A.H.M. Smeets, Jun 03 2019
Comments