cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 75 results. Next

A175299 a(n) = the smallest positive integer such that A175298(a(n)) = the n-th positive integer that is a palindrome when written in binary.

Original entry on oeis.org

1, 2, 4, 6, 8, 10, 16, 20, 18, 22, 32, 36, 34, 38, 64, 72, 68, 76, 66, 74, 70, 78, 128, 136, 132, 140, 130, 138, 134, 142, 256, 272, 264, 280, 260, 276, 268, 284, 258, 274, 266, 282, 262, 278, 270, 286, 512, 528, 520, 536, 516, 532, 524, 540, 514, 530, 522
Offset: 1

Views

Author

Leroy Quet, Mar 24 2010

Keywords

Crossrefs

Formula

a(n) = 2^floor(log_2(P(n))) + P(n)(mod 2^(floor(log_2(P(n))/2)+1)) -1, where P(n) = the n-th positive integer that is a palindrome when written in binary.

Extensions

More terms from Nathaniel Johnston, Nov 18 2010

A261423 Largest palindrome <= n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 77, 77
Offset: 0

Views

Author

N. J. A. Sloane, Aug 28 2015

Keywords

Comments

Might be called the palindromic floor function.
Let P(n) = n with the second half of its digits replaced by the first half of the digits in reverse order. If P(n) <= n, then a(n) = P(n), else if n=10^k then a(n) = n-1, else a(n) = P(n-10^floor(d/2)), where d is the number of digits of n. - M. F. Hasler, Sep 08 2015
The largest differences of n - a(n) occur for n = m*R(2k) - 1, where 1 <= m <= 9 and R(k)=(10^k-1)/9. In this case, n - a(n) = 1.1*10^k - 1. - M. F. Hasler, Sep 05 2018

Crossrefs

Cf. A002113, A261424, A261914 (previous palindrome).
Cf. A262038.
Sequences related to palindromic floor and ceiling: A175298, A206913, A206914, A261423, A262038, and the large block of consecutive sequences beginning at A265509.
A262257(n) = Levenshtein distance between n and a(n). - Reinhard Zumkeller, Sep 16 2015

Programs

  • Haskell
    a261423 n = a261423_list !! n
    a261423_list = tail a261914_list  -- Reinhard Zumkeller, Sep 16 2015
    
  • Maple
    # P has list of palindromes
    palfloor:=proc(n) global P; local i;
    for i from 1 to nops(P) do
       if P[i]=n then return(n); fi;
       if P[i]>n then return(P[i-1]); fi;
    od:
    end;
  • Mathematica
    palQ[n_] := Block[{d = IntegerDigits@ n}, d == Reverse@ d]; Table[k = n;
    While[Nand[palQ@ k, k > -1], k--]; k, {n, 0, 78}] (* Michael De Vlieger, Sep 09 2015 *)
  • PARI
    A261423(n,d=digits(n),m=sum(k=1,#d\2,d[k]*10^(k-1)))={if( n%10^(#d\2)M. F. Hasler, Sep 08 2015, minor edit on Sep 05 2018
    
  • Python
    def P(n):
        s = str(n); h = s[:(len(s)+1)//2]; return int(h + h[-1-len(s)%2::-1])
    def a(n):
        s = str(n)
        if s == '1'+'0'*(len(s)-1) and n > 1: return n - 1
        Pn = P(n)
        return Pn if Pn <= n else P(n - 10**(len(s)//2))
    print([a(n) for n in range(79)]) # Michael S. Branicky, Jun 25 2021

Formula

n - a(n) < 1.1*10^floor(d/2), where d = floor(log_10(n)) + 1 is the number of digits of n. - M. F. Hasler, Sep 05 2018

A262038 Least palindrome >= n.

Original entry on oeis.org

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, 33, 33, 33, 33, 33, 33, 33, 33, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 55, 55, 55, 55, 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
Offset: 0

Views

Author

M. F. Hasler, Sep 08 2015

Keywords

Comments

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.
Might also be called palindromic ceiling function in analogy to the name "palindromic floor" proposed for A261423.

Crossrefs

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

Programs

  • Haskell
    a262038 n = a262038_list !! n
    a262038_list = f 0 a002113_list where
       f n ps'@(p:ps) = p : f (n + 1) (if p > n then ps' else ps)
    -- Reinhard Zumkeller, Sep 16 2015
    
  • Mathematica
    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 *)
  • 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]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
    
  • Python
    def A262038(n):
        sl = len(str(n))
        l = sl>>1
        if sl&1:
            w = 10**l
            n2 = w*10
            for y in range(n//(10**l),n2):
                k, m = y//10, 0
                while k >= 10:
                    k, r = divmod(k,10)
                    m = 10*m + r
                z = y*w + 10*m + k
                if z >= n:
                    return z
        else:
            w = 10**(l-1)
            n2 = w*10
            for y in range(n//(10**l),n2):
                k, m = y, 0
                while k >= 10:
                    k, r = divmod(k,10)
                    m = 10*m + r
                z = y*n2 + 10*m + k
                if z >= n:
                    return z # Chai Wah Wu, Sep 14 2022

A206913 Greatest binary palindrome <= n; the binary palindrome floor function.

Original entry on oeis.org

0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 9, 9, 9, 9, 15, 15, 17, 17, 17, 17, 21, 21, 21, 21, 21, 21, 27, 27, 27, 27, 31, 31, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 45, 45, 45, 45, 45, 45, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 63, 63, 65, 65, 65, 65
Offset: 0

Views

Author

Hieronymus Fischer, Feb 13 2012

Keywords

Comments

Also the greatest binary palindrome < n + 1;
For n > 0, a(n-1) is the greatest binary palindrome < n.

Examples

			a(0) = 0 since 0 is the greatest binary palindrome <= 0;
a(1) = 1 since 1 is the greatest binary palindrome <= 1;
a(2) = 1 since 1 is the greatest binary palindrome <= 2;
a(3) = 3 since 3 is the greatest binary palindrome <= 3.
		

Crossrefs

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

Programs

  • Haskell
    a206913 n = last $ takeWhile (<= n) a006995_list
    -- Reinhard Zumkeller, Feb 27 2012

Formula

Let n > 2, p = 1 + 2*floor((n-1)/2), m = floor(log_2(p)), q = floor((m+1)/2), s = floor(log_2(p-2^q)),
F(x, r) = floor(x/2^q)*2^q + Sum_{k = 0...q - 1} (floor(x/2^(r-k)) mod 2)*2^k;
If F(p, m) <= n then a(n) = F(p, m), otherwise a(n) = F(p-2^q, s).
By definition: F(p, m) = floor(p/2^q)*2^q + A030101(p) mod 2^q; also: F(p-2^q, s) = floor((p-2^q)/2^q)*2^q + A030101(p-2^q) mod 2^q; [Edited and corrected by Hieronymus Fischer, Sep 08 2018]
a(n) = A006995(A206915(n));
a(n) = A006995(A206915(A206914(n+1))-1);
a(n) = A006995(A206916(A206914(n+1))-1).

A206914 Least binary palindrome >= n; the binary palindrome ceiling function.

Original entry on oeis.org

0, 1, 3, 3, 5, 5, 7, 7, 9, 9, 15, 15, 15, 15, 15, 15, 17, 17, 21, 21, 21, 21, 27, 27, 27, 27, 27, 27, 31, 31, 31, 31, 33, 33, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 51, 51, 51, 51, 51, 51, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 65, 65, 73, 73
Offset: 0

Views

Author

Hieronymus Fischer, Feb 15 2012

Keywords

Comments

For n > 0 also the least binary palindrome > n - 1;
a(n+1) is the least binary palindrome > n

Examples

			a(0) = 0 since 0 is the least binary palindrome >= 0;
a(1) = 1 since 1 is the least binary palindrome >= 1;
a(2) = 3 since 3 is the least binary palindrome >= 2;
a(5) = 5 since 5 is the least binary palindrome >= 5;
		

Crossrefs

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

Programs

  • Haskell
    a206914 n = head $ dropWhile (< n) a006995_list
    -- Reinhard Zumkeller, Feb 27 2012

Formula

a(n) = A006995(A206916(n));
a(n) = A006995(A206916(A206913(n-1))+1);
a(n) = A006995(A206915(A206913(n-1))+1);

A265509 a(n) = largest base-2 palindrome m <= 2n+1 such that every base-2 digit of m is <= the corresponding digit of 2n+1; m is written in base 10.

Original entry on oeis.org

1, 3, 5, 7, 9, 9, 9, 15, 17, 17, 21, 21, 17, 27, 21, 31, 33, 33, 33, 33, 33, 33, 45, 45, 33, 51, 33, 51, 33, 51, 45, 63, 65, 65, 65, 65, 73, 73, 73, 73, 65, 65, 85, 85, 73, 73, 93, 93, 65, 99, 65, 99, 73, 107, 73, 107, 65, 99, 85, 119, 73, 107, 93, 127, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 153
Offset: 0

Views

Author

N. J. A. Sloane, Dec 09 2015

Keywords

Comments

A007088(a(n)) = A265510(n). - Reinhard Zumkeller, Dec 11 2015

Crossrefs

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

Programs

  • Haskell
    a265509 n = a265509_list !! n
    a265509_list = f (tail a030308_tabf) [[]] where
       f (bs:_:bss) pss = y : f bss pss' where
         y = foldr (\d v -> 2 * v + d) 0 ys
         (ys:_) = dropWhile (\ps -> not $ and $ zipWith (<=) ps bs) pss'
         pss' = if bs /= reverse bs then pss else bs : pss
    -- Reinhard Zumkeller, Dec 11 2015
  • Maple
    ispal := proc(n) # test for base-b palindrome
    local L, Ln, i;
    global b;
        L := convert(n, base, b);
        Ln := nops(L);
        for i to floor(1/2*Ln) do
            if L[i] <> L[Ln + 1 - i] then return false end if
        end do;
        return true
    end proc
    # find max pal <= n and in base-b shadow of n, write in base 10
    under10:=proc(n) global b;
    local t1,t2,i,m,sw1,L2;
    if n mod b = 0 then return(0); fi;
    t1:=convert(n,base,b);
    for m from n by -1 to 0 do
    if ispal(m) then
       t2:=convert(m,base,b);
       L2:=nops(t2);
       sw1:=1;
       for i from 1 to L2 do
          if t2[i] > t1[i] then sw1:=-1; break; fi;
                          od:
       if sw1=1 then return(m); fi;
    fi;
                           od;
    end proc;
    b:=2; [seq(under10(2*n+1),n=0..144)]; # Gives A265509
    # find max pal <= n and in base-b shadow of n, write in base b
    underb:=proc(n) global b;
    local t1,t2,i,m,mb,sw1,L2;
    if n mod b = 0 then return(0); fi;
    t1:=convert(n,base,b);
    for m from n by -1 to 0 do
    if ispal(m) then
       t2:=convert(m,base,b);
       L2:=nops(t2);
       sw1:=1;
       for i from 1 to L2 do
          if t2[i] > t1[i] then sw1:=-1; break; fi;
                          od:
       if sw1=1 then mb:=add(t2[i]*10^(i-1), i=1..L2); return(mb); fi;
    fi;
                           od;
    end proc;
    b:=2; [seq(underb(2*n+1),n=0..144)]; # Gives A265510
  • Mathematica
    A265509 = FromDigits[Min /@ Transpose[{#, Reverse@#}], 2] &@IntegerDigits[2 # + 1, 2] & (* JungHwan Min, Aug 22 2016 *)

A175297 Convert n to binary. AND each respective digit of binary n and binary A030101(n), where A030101(n) is the reversal of the order of the digits in the binary representation of n (given in decimal). a(n) is the decimal value of the result.

Original entry on oeis.org

1, 0, 3, 0, 5, 2, 7, 0, 9, 0, 9, 0, 9, 6, 15, 0, 17, 0, 17, 4, 21, 4, 21, 0, 17, 10, 27, 4, 21, 14, 31, 0, 33, 0, 33, 0, 33, 0, 33, 0, 33, 0, 33, 12, 45, 12, 45, 0, 33, 18, 51, 0, 33, 18, 51, 0, 33, 18, 51, 12, 45, 30, 63, 0, 65, 0, 65, 0, 65, 0, 65, 8, 73, 8, 73, 8, 73, 8, 73, 0, 65, 0, 65
Offset: 1

Views

Author

Leroy Quet, Mar 24 2010

Keywords

Comments

By "respective" digits of binary n and binary A030101(n), the rightmost digit of A030101(n) ( which is a 1) is AND'ed with the rightmost digit of n. A030101(n) is represented with the appropriate number of leading 0's.

Examples

			20 in binary is 10100. The reversal of the binary digits is 00101. So, from leftmost to rightmost respective digits, we AND 10100 and 00101: 1 AND 0 = 0. 0 AND 0 = 0. 1 AND 1 = 1. 0 AND 0 = 0. And 0 AND 1 = 1. So, 10100 AND 00101 is 100, which is 4 in decimal. So a(20) = 4.
		

Crossrefs

Programs

  • Mathematica
    Table[f = IntegerDigits[x, 2]; f = f + Reverse[f]; FromDigits[ Table[If[f[[r]] == 2, 1, 0], {r, 1, Length[f]}], 2], {x, 83}] (* Dylan Hamilton, Oct 15 2010 *)
    Table[With[{d = IntegerDigits[n, 2]}, FromDigits[#, 2] &@ Map[BitAnd @@ # &, Transpose@{d, Reverse@ d}]], {n, 83}] (* Michael De Vlieger, Sep 03 2017 *)

Extensions

Extended, with redundant initial entries included, by Dylan Hamilton, Oct 15 2010

A175919 Convert n to binary. XOR each respective digit of binary n and binary A030101(n), where A030101(n) is the reversal of the order of the digits in the binary representation of n (given in decimal). a(n) is the decimal value of the result.

Original entry on oeis.org

0, 0, 3, 0, 5, 0, 5, 0, 9, 0, 15, 6, 15, 6, 9, 0, 17, 0, 27, 10, 17, 0, 27, 10, 27, 10, 17, 0, 27, 10, 17, 0, 33, 0, 51, 18, 45, 12, 63, 30, 45, 12, 63, 30, 33, 0, 51, 18, 51, 18, 33, 0, 63, 30, 45, 12, 63, 30, 45, 12, 51, 18, 33, 0, 65, 0, 99, 34, 85, 20, 119, 54, 65, 0, 99, 34, 85, 20, 119
Offset: 0

Views

Author

Dylan Hamilton, Oct 15 2010

Keywords

Comments

Description format taken from Leroy Quet's OR and AND gate sequences for consistency.

Crossrefs

Or A175298 and And A175297 gate sequences. The rest of the equivalent sequences for other gates are adjacent.

Programs

  • Mathematica
    Table[f = IntegerDigits[x, 2]; f = f + Reverse[f]; FromDigits[ Table[If[OddQ[f[[r]]], 1, 0], {r, 1, Length[f]}], 2], {x, STARTPOINT,ENDPOINT}]

Formula

a(n) = A003987(n, A030101(n)).

A265510 a(n) = largest base-2 palindrome m <= 2n+1 such that every base-2 digit of m is <= the corresponding digit of 2n+1; m is written in base 2.

Original entry on oeis.org

1, 11, 101, 111, 1001, 1001, 1001, 1111, 10001, 10001, 10101, 10101, 10001, 11011, 10101, 11111, 100001, 100001, 100001, 100001, 100001, 100001, 101101, 101101, 100001, 110011, 100001, 110011, 100001, 110011, 101101, 111111, 1000001, 1000001, 1000001, 1000001, 1001001, 1001001, 1001001, 1001001, 1000001, 1000001
Offset: 0

Views

Author

N. J. A. Sloane, Dec 09 2015

Keywords

Comments

a(n) = A007088(A265509(n)). - Reinhard Zumkeller, Dec 11 2015

Crossrefs

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

Programs

A265525 a(n) = largest base-10 palindrome m <= n such that every base-10 digit of m is <= the corresponding digit of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 0, 11, 22, 22, 22, 22, 22, 22, 22, 22, 0, 11, 22, 33, 33, 33, 33, 33, 33, 33, 0, 11, 22, 33, 44, 44, 44, 44, 44, 44, 0, 11, 22, 33, 44, 55, 55, 55, 55, 55, 0, 11, 22, 33, 44, 55, 66, 66, 66, 66, 0, 11, 22, 33, 44, 55, 66, 77, 77, 77, 0, 11, 22, 33
Offset: 0

Views

Author

N. J. A. Sloane, Dec 09 2015

Keywords

Crossrefs

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

Programs

  • Haskell
    a265525 n = a265525_list !! n
    a265525_list = f a031298_tabf [[]] where
       f (ds:dss) pss = y : f dss pss' where
         y = foldr (\d v -> 10 * v + d) 0 ys
         (ys:_) = dropWhile (\ps -> not $ and $ zipWith (<=) ps ds) pss'
         pss' = if ds /= reverse ds then pss else ds : pss
    -- Reinhard Zumkeller, Dec 11 2015
  • Maple
    ispal := proc(n) # test for base-b palindrome
    local L, Ln, i;
    global b;
    L := convert(n, base, b);
    Ln := nops(L);
    for i to floor(1/2*Ln) do
    if L[i] <> L[Ln + 1 - i] then return false end if
    end do;
    return true
    end proc
    # find max pal <= n and in base-b shadow of n, write in base 10
    under10:=proc(n) global b;
    local t1,t2,i,m,sw1,L2;
    if n mod b = 0 then return(0); fi;
    t1:=convert(n,base,b);
    for m from n by -1 to 0 do
    if ispal(m) then
    t2:=convert(m,base,b);
    L2:=nops(t2);
    sw1:=1;
    for i from 1 to L2 do
    if t2[i] > t1[i] then sw1:=-1; break; fi;
    od:
    if sw1=1 then return(m); fi;
    fi;
    od;
    end proc;
    b:=10; [seq(under10(n),n=0..144)]; # Gives A265525
Showing 1-10 of 75 results. Next