|
|
A099280
|
|
2^n-th palindromic number.
|
|
3
|
|
|
1, 2, 4, 8, 77, 232, 555, 2992, 15751, 41314, 92529, 1049401, 3097903, 7193917, 63855836, 227696722, 555373555, 3107337013, 16214541261, 42428982424, 94857775849, 1097153517901, 3194305034913, 7388609068837, 67772177127776
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,2
|
|
LINKS
|
|
|
MATHEMATICA
|
NextPalindrome[n_] := Block[ {l = Floor[ Log[10, n] + 1], idn = IntegerDigits[n]}, If[ Union[ idn] == {9}, Return[n + 2], If[l < 2, Return[n + 1], If[ FromDigits[ Reverse[ Take[ idn, Ceiling[l/2]]]] FromDigits[ Take[ idn, -Ceiling[l/2]]], FromDigits[ Join[ Take[ idn, Ceiling[l/2]], Reverse[ Take[ idn, Floor[l/2]]] ]], idfhn = FromDigits[ Take[ idn, Ceiling[l/2]]] + 1; idp = FromDigits[ Join[ IntegerDigits[ idfhn], Drop[ Reverse[ IntegerDigits[ idfhn]], Mod[l, 2]]]] ]]]]; k = 1; np = 0; Do[ While[np = NextPalindrome[np]; k != 2^n, k++ ]; Print[np], {n, 26}]
|
|
PROG
|
(Python)
if n == 0: return 1
m = 1<<n-1
k = (m<<1)+1
y = 10*(x:=10**(len(str(m))-1))
return (c:=k-x)*x+int(str(c)[-2::-1]or 0) if k<x+y else (c:=k-y)*y+int(str(c)[-1::-1]or 0) # Chai Wah Wu, Jun 13 2024
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|