|
|
A259374
|
|
Palindromic numbers in bases 3 and 5 written in base 10.
|
|
16
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,3
|
|
COMMENTS
|
0 is only 0 regardless of the base,
1 is only 1 regardless of the base,
2 on the other hand is also 10 in base 2, denoted as 10_2,
3 is 3 in all bases greater than 3, but is 11_2 and 10_3.
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
52 is in the sequence because 52_10 = 202_5 = 1221_3.
|
|
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 *)
|
|
PROG
|
(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
|
|
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.
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|