The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A262038 Least palindrome >= n. 79

%I #31 Sep 15 2022 02:14:13

%S 0,1,2,3,4,5,6,7,8,9,11,11,22,22,22,22,22,22,22,22,22,22,22,33,33,33,

%T 33,33,33,33,33,33,33,33,44,44,44,44,44,44,44,44,44,44,44,55,55,55,55,

%U 55,55,55,55,55,55,55,66,66,66,66,66,66,66,66,66,66,66,77,77,77,77,77,77,77,77,77,77

%N Least palindrome >= n.

%C Could be called nextpalindrome() in analogy to the nextprime() function A007918. As for the latter (A151800), there is the variant "next strictly larger palindrome" which equals a(n+1), and thus differs from a(n) iff n is a palindrome; see PARI code.

%C Might also be called palindromic ceiling function in analogy to the name "palindromic floor" proposed for A261423.

%H M. F. Hasler, <a href="/A262038/b262038.txt">Table of n, a(n) for n = 0..10000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PalindromicNumber.html">Palindromic Number</a>

%H Wikipedia, <a href="http://www.wikipedia.org/wiki/Palindromic_number">Palindromic number</a>

%H <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>

%t palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d]; Table[k = n; While[! palQ@ k, k++]; k, {n, 0, 80}] (* _Michael De Vlieger_, Sep 09 2015 *)

%o (PARI) {A262038(n, d=digits(n), p(d)=sum(i=1, #d\2, (10^(i-1)+10^(#d-i))*d[i],if(bittest(#d,0),10^(#d\2)*d[#d\2+1])))= for(i=(#d+3)\2,#d,d[i]>d[#d+1-i]&&break;(d[i]<d[#d+1-i]||i==#d)&&return(p(d)));n<10&&return(n); forstep(i=(#d+1)\2,1,-1,d[i]++>9||return(p(d));d[i]=0);10^#d+1} \\ For a function "next strictly larger palindrome", delete the i==#d and n<10... part. - _M. F. Hasler_, Sep 09 2015

%o (Haskell)

%o a262038 n = a262038_list !! n

%o a262038_list = f 0 a002113_list where

%o f n ps'@(p:ps) = p : f (n + 1) (if p > n then ps' else ps)

%o -- _Reinhard Zumkeller_, Sep 16 2015

%o (Python)

%o def A262038(n):

%o sl = len(str(n))

%o l = sl>>1

%o if sl&1:

%o w = 10**l

%o n2 = w*10

%o for y in range(n//(10**l),n2):

%o k, m = y//10, 0

%o while k >= 10:

%o k, r = divmod(k,10)

%o m = 10*m + r

%o z = y*w + 10*m + k

%o if z >= n:

%o return z

%o else:

%o w = 10**(l-1)

%o n2 = w*10

%o for y in range(n//(10**l),n2):

%o k, m = y, 0

%o while k >= 10:

%o k, r = divmod(k,10)

%o m = 10*m + r

%o z = y*n2 + 10*m + k

%o if z >= n:

%o return z # _Chai Wah Wu_, Sep 14 2022

%Y Cf. A002113, A261423, A262037.

%Y Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.

%K nonn,base

%O 0,3

%A _M. F. Hasler_, Sep 08 2015

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 20 05:07 EDT 2024. Contains 372703 sequences. (Running on oeis4.)