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.

Previous Showing 11-18 of 18 results.

A048700 Binary palindromes of odd length (written in base 10).

Original entry on oeis.org

1, 5, 7, 17, 21, 27, 31, 65, 73, 85, 93, 99, 107, 119, 127, 257, 273, 297, 313, 325, 341, 365, 381, 387, 403, 427, 443, 455, 471, 495, 511, 1025, 1057, 1105, 1137, 1161, 1193, 1241, 1273, 1285, 1317, 1365, 1397, 1421, 1453, 1501, 1533, 1539, 1571, 1619, 1651
Offset: 1

Views

Author

Antti Karttunen, Mar 07 1999

Keywords

Comments

Note: you get A006995 (all binary palindromes) if you take (after zero) alternatively 2^n (starting from 2^0 = 1) terms from A048700 and as many from A048701 and then each time, twice as many from both.
A178225(a(n)) = 1. - Reinhard Zumkeller, Oct 21 2011
Comment from Altug Alkan, Dec 03 2015: (Start)
a(6*k) is divisible by 9 for k > 0.
a(3*k+(-1)^k-2) is divisible by 3 for k > 1.
The minimum value of a(n+1) - a(n) occurs when n = 2.
A014551(n) appears in this sequence for n > 0. (End)

Crossrefs

Cf. A048701 (binary palindromes of even length), A002113 (decimal palindromes), A006995 (all binary palindromes).
Cf. also A178225.

Programs

  • Haskell
    import Data.Set (singleton, deleteFindMin, insert)
    import Data.List (unfoldr)
    a048700 n = a048700_list !! (n-1)
    a048700_list = f 1 $ singleton 1 where
       f z s = m : f (z+1) (insert (c 0) (insert (c 1) s')) where
         c d = foldl (\v d -> 2 * v + d) 0 $ (reverse b) ++ [d] ++ b
         b = unfoldr
             (\x -> if x == 0 then Nothing else Just $ swap $ divMod x 2) z
         (m,s') = deleteFindMin s
    -- Reinhard Zumkeller, Oct 21 2011
    
  • Maple
    bit_i := (x,i) -> `mod`(floor(x/(2^i)),2);
    floor_log_2 := proc(n) local nn,i: nn := n; for i from -1 to n do if(0 = nn) then RETURN(i); fi: nn := floor(nn/2); od: end:
  • Mathematica
    Select[Range@ 1651, # == Reverse@ # && OddQ@ Length@ # &@ IntegerDigits[#, 2] &] (* Michael De Vlieger, Dec 03 2015 *)
  • PARI
    {a(n) = local(f); if( n<1, 0, f = length(binary(n)) - 1; 2^f*n + sum(i=1, f, bittest(n,i) * 2^(f-i)))}; /* Michael Somos, Nov 27 2002 */
    
  • Python
    def A048700(n):
        s = bin(n)[2:]
        return int(s+s[-2::-1],2) # Chai Wah Wu, Feb 26 2021

Formula

a(n) = (2^(floor_log_2(n)))*n + sum('(bit_i(n, i)*(2^(floor_log_2(n)-i)))', 'i'=1..floor_log_2(n));
a(A047264(n)) mod 3 = 0, for n > 1. - Altug Alkan, Dec 03 2015

A141707 Least k>0 such that (2n-1)k is palindromic in base 2.

Original entry on oeis.org

1, 1, 1, 1, 1, 3, 5, 1, 1, 27, 1, 89, 13, 1, 49, 1, 1, 13, 69, 5, 25, 3, 1, 103, 29, 1, 63, 3, 9, 103, 7, 1, 1, 19, 37, 147, 1, 13, 3, 19, 11, 45, 1, 37, 23, 3, 1, 27, 61, 1, 233, 47, 13, 1, 21, 23, 59, 525, 5, 1, 93, 23, 41, 1, 1, 49, 27, 13, 187, 87, 269, 15, 111, 13, 29, 7, 1, 13, 3
Offset: 1

Views

Author

M. F. Hasler, Jul 17 2008

Keywords

Comments

Even numbers cannot be palindromic in base 2 (unless leading zeros are considered), that's why we search only for odd numbers 2n-1 the k-values such that k(2n-1) is palindromic in base 2. Obviously they are necessarily also odd.
a(A044051(n)) = 1. - Reinhard Zumkeller, Apr 20 2015

Examples

			a(1..5)=1 since 1,3,5,7,9 are already palindromic in base 2.
a(6)=3 since 2*6-1=11 and 2*11=22 are not palindromic in base 2, but 3*11=33 is.
		

Crossrefs

Programs

  • Haskell
    a141707 n = head [k | k <- [1, 3 ..], a178225 (k * (2 * n - 1)) == 1]
    -- Reinhard Zumkeller, Apr 20 2015
    
  • Mathematica
    lkp[n_]:=Module[{k=1,n2=2n-1},While[IntegerDigits[k*n2,2]!= Reverse[ IntegerDigits[ k*n2,2]],k++];k]; Array[lkp,80] (* Harvey P. Dale, Mar 19 2016 *)
  • PARI
    A141707(n,L=10^9)={ n=2*n-1; forstep(k=1,L,2, binary(k*n)-vecextract(binary(k*n),"-1..1") || return(k))}
    
  • Python
    def binpal(n): b = bin(n)[2:]; return b == b[::-1]
    def a(n):
        m = 2*n - 1
        km = m
        while not binpal(km): km += m
        return km//m
    print([a(n) for n in range(1, 80)]) # Michael S. Branicky, Mar 20 2022

A141709 Least positive multiple of n which is palindromic in base 2, allowing for leading zeros (or: ignoring trailing zeros).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 33, 12, 65, 14, 15, 16, 17, 18, 513, 20, 21, 66, 2047, 24, 325, 130, 27, 28, 1421, 30, 31, 32, 33, 34, 455, 36, 2553, 1026, 195, 40, 1025, 42, 129, 132, 45, 4094, 4841, 48, 1421, 650, 51, 260, 3339, 54, 165, 56, 513, 2842, 6077, 60, 427, 62
Offset: 1

Views

Author

M. F. Hasler, Jul 17 2008

Keywords

Comments

Even numbers cannot be palindromic in base 2, unless leading zeros are considered (or, equivalently, resp. more precisely, trailing zeros are discarded). This is done in this version of A141708, which therefore does not need to be restricted to odd n as it has been done for A141707 and A141708.

Crossrefs

Programs

  • Haskell
    a141709 n = until ((== 1) . a178225 . a000265) (+ n) n
    -- Reinhard Zumkeller, Nov 06 2012
  • Mathematica
    notpalbinQ[i_]:=Module[{id=IntegerDigits[i,2]},While[Last[id]==0,id=Most[id]];id!= Reverse[id]]; lm[n_]:=Module[{k=1},While[notpalbinQ[k n],k++];k n]; Array[lm,70] (* Harvey P. Dale, Dec 28 2011 *)
  • PARI
    A141709(n)=forstep(k=n,10^9,n,vecextract(t=binary(k>>valuation(k,2)),"-1..1")-t || return(k))
    

Formula

A178225(A000265(a(n))) = 1. - Reinhard Zumkeller, Nov 06 2012

A164861 Odd positive integers that are not palindromes when written in binary.

Original entry on oeis.org

11, 13, 19, 23, 25, 29, 35, 37, 39, 41, 43, 47, 49, 53, 55, 57, 59, 61, 67, 69, 71, 75, 77, 79, 81, 83, 87, 89, 91, 95, 97, 101, 103, 105, 109, 111, 113, 115, 117, 121, 123, 125, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 155, 157, 159, 161, 163, 167
Offset: 1

Views

Author

Leroy Quet, Aug 28 2009

Keywords

Comments

These are the odd members of A154809.

Crossrefs

Cf. A154809.

Programs

  • Haskell
    a164861 n = a164861_list !! (n-1)
    a164861_list = filter ((== 0) . a178225) a005408_list
    -- Reinhard Zumkeller, Oct 21 2011
  • Mathematica
    npbQ[n_]:=Module[{idn2=IntegerDigits[n,2]},idn2!=Reverse[idn2]]; Select[ Range[1,201,2],npbQ] (* Harvey P. Dale, May 17 2012 *)

Formula

A178225(a(n)) * (1 - A000035(a(n))) = 0. [Reinhard Zumkeller, Oct 21 2011]

Extensions

Extended by Ray Chandler, Mar 14 2010

A164126 First differences of A006995.

Original entry on oeis.org

1, 2, 2, 2, 2, 6, 2, 4, 6, 4, 2, 12, 6, 12, 2, 8, 12, 8, 6, 8, 12, 8, 2, 24, 12, 24, 6, 24, 12, 24, 2, 16, 24, 16, 12, 16, 24, 16, 6, 16, 24, 16, 12, 16, 24, 16, 2, 48, 24, 48, 12, 48, 24, 48, 6, 48, 24, 48, 12, 48, 24, 48, 2, 32, 48, 32, 24, 32, 48, 32, 12, 32, 48, 32, 24, 32, 48, 32, 6
Offset: 1

Views

Author

Keywords

Comments

Contribution from Hieronymus Fischer, Feb 18 2012: (Start)
From the formula section it follows that a(2^m - 1 + 2^(m-1) - k) = a(2^m - 1 + k) for 0 <= k <= 2^(m-1), as well as a(2^m - 1 + 2^(m-1) - k) = 2 for k=0, 2^(m-1) and a(2^m - 1 + 2^(m-1) - k) = 6 for k=2^(m-2), hence, starting from positions n=2^m-1, the following 2^(m-1) terms form symmetric tuples limited on the left and on the right by a '2' and always having a '6' as the center element.
Example: for n = 15 = 2^4 - 1, we have the (2^3+1)-tuple (2,8,12,8,6,8,12,8,2).
Further on, since a(2^m - 1 + 2^(m-1) + k) = a(2^(m+1) - 1 - k) for 0 <= k <= 2^(m-1) an analogous statement holds true for starting positions n = 2^m + 2^(m-1) - 1.
Example: for n = 23 = 2^4 + 2^3 - 1, we find the (2^3+1)-tuple (2,24,12,24,6,24,12,24,2).
If we group the sequence terms according to the value of m=floor(log_2(n)), writing those terms together in separate lines and opening each new line for n >= 2^m + 2^(m-1), then a kind of a 'logarithmic shaped' cone end will be formed, where both the symmetry and the calculation rules become obvious. The first 63 terms are depicted below:
1
2
2
2 2
6 2
4 6 4 2
12 6 12 2
8 12 8 6 8 12 8 2
24 12 24 6 24 12 24 2
16 24 16 12 16 24 16 6 16 24 16 12 16 24 16 2
48 24 48 12 48 24 48 6 48 24 48 12 48 24 48 2
.
(End)
Decremented by 1, also the sequence of run lengths of 0's in A178225. - Hieronymus Fischer, Feb 19 2012

Examples

			a(1) = A006995(2) - A006995(1) = 1 - 0 = 1.
		

Crossrefs

Programs

  • Mathematica
    f[n_]:=FromDigits[RealDigits[n,2][[1]]]==FromDigits[Reverse[RealDigits[n, 2][[1]]]]; a=1;lst={};Do[If[f[n],AppendTo[lst,n-a];a=n],{n,1,8!,1}]; lst
  • Python
    def A164126(n):
        if n == 1: return 1
        m = (a:=1<<(l:=n.bit_length()-2))|(n&a-1)
        k = (m<Chai Wah Wu, Jun 11 2024

Formula

a(n) = A006995(n+1) - A006995(n).
Contribution from Hieronymus Fischer, Feb 17 2012: (Start)
a(4*2^m - 1) = a(6*2^m - 1) = 2;
a(5*2^m - 1) = a(7*2^m - 1) = 6 (for m > 0);
Let m = floor(log_2(n)), then
Case 1: a(n) = 2, if n+1 = 2^(m+1) or n+1 = 3*2^(m-1);
Case 2: a(n) = 2^(m-1), if n = 0(mod 2) and n < 3*2^(m-1);
Case 3: a(n) = 3*2^(m-1), if n = 0(mod 2) and n >= 3*2^(m-1);
Case 4: a(n) = 3*2^(m-1)/gcd(n+1-2^m, 2^m), otherwise.
Cases 2-4 above can be combined as
Case 2': a(n) = (2 - (-1)^(n-(n-1)*floor(2*n/(3*2^m))))*2^(m-1)/gcd(n+1-2^m, 2^m).
Recursion formula:
Let m = floor(log_2(n)); then
Case 1: a(n) = 2*a(n-2^(m-1)), if 2^m <= n < 2^m + 2^(m-2) - 1;
Case 2: a(n) = 6, if n = 2^m + 2^(m-2) - 1;
Case 3: a(n) = a(n-2^(m-2)), if 2^m + 2^(m-2) <= n < 2^m + 2^(m-1) - 1;
Case 4: a(n) = 2, if n = 2^m + 2^(m-1) - 1;
Case 5: a(n) = (2 + (-1)^n)*a(n-2^(m-1)), otherwise (which means 2^m + 2^(m-1) <= n < 2^(m+1)).
(End)

Extensions

a(1) changed to 1 and keyword:base added by R. J. Mathar, Aug 26 2009

A178226 Characteristic function of A154809 (numbers that are not binary palindromes).

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Jeremy Gardiner, May 23 2010

Keywords

Comments

a(n)=1 if n is in A154809, a(n)=0 otherwise.
Identical to parity of A086757 (Smallest prime p such that n is a palindrome in base p representation)

Crossrefs

Programs

  • Mathematica
    Table[If[IntegerDigits[n,2]==Reverse[IntegerDigits[n,2]],0,1],{n,0,120}] (* Harvey P. Dale, Aug 07 2023 *)
  • PARI
    A178226(n) = (n!=subst(Polrev(binary(n)),x,2)); \\ Antti Karttunen, Dec 15 2017

Formula

a(n) = 1 - A178225(n). - Antti Karttunen, Dec 15 2017

A206921 Rank of the n-th binary palindrome. The minimal number of iterations A206915(A206915(...A206915(A006995(n))...)) such that the result is not a binary palindrome, a(3)=1.

Original entry on oeis.org

2, 1, 1, 1, 2, 1, 3, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1
Offset: 1

Views

Author

Hieronymus Fischer, Mar 12 2012

Keywords

Comments

The number of iterations such that A006995(n) = A006995(A006995(A006995(...(A206922(n))...))) [For n<>3].

Examples

			a(1)=2, since A006995(1)=0=A006995(A006995(2)) [==> 2 iterations; 2 is not a binary palindrome];
a(3)=1 by definition;
a(4)=1, since A006995(4)=5=A006995(4) [==> 1 iteration; 4 is not a binary palindrome];
a(7)=3, since A006995(7)=15=A006995(A006995(A006995(4))) [==> 3 iterations; 4 is not a binary palindrome];
		

Crossrefs

Programs

Formula

a(n)=k, where k can be determined by the following iteration: set k=0, p(0)=A006995(n). Repeat while A178225(p(k))==1, set k=k+1, p(k)=A206915(p(k-1)) end repeat [for n<>3].
Recursion for n<>3:
Case 1: a(n)=1, if n is not a binary palindrome;
Case 2: a(n)=a(A206915(n))+1, else.
Formally: a(n)=if (A178225(n)==0) then 1 else a(A206915(n))+1

A206922 Root of the n-th binary palindrome. Least number r > 1 such that A006995(n) can be represented by a finite or infinite number of iterations A006995(A006995(A006995(...(...(r))...).

Original entry on oeis.org

2, 2, 3, 4, 4, 6, 4, 8, 6, 10, 11, 12, 13, 14, 4, 16, 8, 18, 19, 20, 6, 22, 23, 24, 25, 26, 10, 28, 29, 30, 11, 32, 12, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 13, 46, 47, 48, 49, 50, 14, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 4, 64, 16, 66, 67, 68
Offset: 1

Views

Author

Hieronymus Fischer, Mar 12 2012

Keywords

Comments

If n is not a binary palindrome, then a(n)=n.
For n>3: a(n)
For n<>3: The number of iterations such that A006995(n)= A006995(A006995(A006995(...(...(r))...) is given by A206921(n).

Examples

			a(1)=2, since A006995(1) = 0 = A006995(A006995(2)).
a(3)=3, since A006995(3) = 3 = A006995(A006995(A006995(...(3)...).
a(7)=4, since A006995(7) = 15 = A006995(A006995(A006995(4)).
a(9)=6, since A006995(9) = 21 = A006995(A006995(6)).
		

Crossrefs

Programs

  • C
    /* C program fragment, omitting formal details, n!=3 */
    k=0;
    p=A006995(n);
    while A178225(p)==1
    {
      k++;
      p=A206915(p);
    }
    return p;

Formula

a(n) <= n for n > 1.
a(n)=p(k), where p(k) can be determined by the following iteration: set k=0, p(0)=A006995(n). Repeat while A178225(p(k))==1, set k=k+1, p(k)=A206915(p(k-1)) end repeat [for n<>3].
Recursion for n<>3:
Case 1: a(n)=n, if n is not a binary palindrome;
Case 2: a(n)=a(A206915(n)), else.
Formally: a(n)=if (A178225(n)==0) then n else a(A206915(n)).
Previous Showing 11-18 of 18 results.