login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A136687
Number of palindromes in the range [0,n] inclusive.
4
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16
OFFSET
0,2
COMMENTS
Partial sums of A136522. [Typo fixed by Colin Barker, Apr 26 2015]
LINKS
FORMULA
a(n) = inv_A002113(A261423(n)), where inv_A002113 is the inverse of A002113, i.e., it yields the index of a palindrome. - M. F. Hasler, Sep 10 2018
MATHEMATICA
palQ[n_]:=Module[{idn=IntegerDigits[n]}, idn==Reverse[idn]]; Accumulate[ Table[ If[palQ[n], 1, 0], {n, 0, 80}]] (* Harvey P. Dale, May 11 2014 *)
PROG
(PARI) A136687(n)=inv_A002113(A261423(n)) \\ M. F. Hasler, Sep 09 2018
(Python)
def A136687(n):
l = len(s:=str(n))
k = l+1>>1
return n//10**(l-k)-(int(s[k-1::-1])>n%10**k)+10**(k-1+(l&1^1)) # Chai Wah Wu, Jul 24 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Apr 21 2008
STATUS
approved