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 31 results. Next

A063250 Number of binary right-rotations (iterations of A038572) to reach fixed point.

Original entry on oeis.org

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

Views

Author

Marc LeBrun, Jul 11 2001

Keywords

Comments

a(n) = 0 when n is a fixed point of form 2^k-1 left-rotation analog appears to be same as A048881.
a(n) is the position of the leftmost 0 in the binary expansion of n (starting from the least significant bit). For example, 44 = 101100_2 and the leftmost 0 is in position 5, so a(44) = 5. - Chai Wah Wu, Mar 09 2025

Examples

			a(11)=3 since under right-rotation 11 -> 13 -> 14 -> 7 and 7 is a fixed point.
		

Crossrefs

Programs

  • Mathematica
    Table[Length[FixedPointList[FromDigits[RotateRight[IntegerDigits[ #,2]], 2]&, n]]-2,{n,0,110}] (* Harvey P. Dale, Dec 23 2011 *)
  • Python
    def a(n):
        if n<2: return 0
        b=bin(n)[2:]
        s=0
        while "0" in b:
            N=int(b[-1] + b[:-1], 2)
            s+=1
            b=bin(N)[2:]
        return s
    print([a(n) for n in range(105)]) # Indranil Ghosh, May 25 2017
    
  • Python
    def A063250(n): return 0 if (t:=bin(n)[2:].find('0'))==-1 else n.bit_length()-t # Chai Wah Wu, Mar 09 2025

Formula

If n+1 is a power of 2 then a(n)=0 otherwise a(n) = 1 + a(floor(n/2)).
Conjectured g.f.: 1/(1-x) * Sum_{j>=0} x^(2^j) - (1-x^(2^j)) * Sum_{k>=1} x^((2^j)*(2^k-1)). - Mikhail Kurkov, Sep 29 2019

A273105 a(n) = A038572(n) + A006257(n), sum of the two numbers obtained by rotating the binary representation of n by one place to the right and to the left.

Original entry on oeis.org

0, 2, 2, 6, 3, 9, 8, 14, 5, 15, 10, 20, 15, 25, 20, 30, 9, 27, 14, 32, 19, 37, 24, 42, 29, 47, 34, 52, 39, 57, 44, 62, 17, 51, 22, 56, 27, 61, 32, 66, 37, 71, 42, 76, 47, 81, 52, 86, 57, 91, 62, 96, 67, 101, 72, 106, 77, 111, 82, 116, 87, 121, 92, 126, 33, 99
Offset: 0

Views

Author

Alex Ratushnyak, May 15 2016

Keywords

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2] &@ IntegerDigits[n, 2], {n, 0, 65}] (* Michael De Vlieger, May 17 2016 *)
  • Python
    print('0', end=',')
    for n in range(1,1000):
        BL = len(bin(n))-2
        x = (n>>1) + ((n&1) << (BL-1))   # A038572(n)
        x+= (n*2) - (1<A006257(n)  for n>0
        print(str(x), end=',')

A273106 Numbers representable as ror(k)+rol(k), where ror(k)=A038572(k) is k rotated one binary place to the right, rol(k)=A006257(k) is k rotated one binary place to the left.

Original entry on oeis.org

0, 2, 3, 5, 6, 8, 9, 10, 14, 15, 17, 19, 20, 22, 24, 25, 27, 29, 30, 32, 33, 34, 37, 38, 39, 42, 43, 44, 47, 48, 51, 52, 53, 56, 57, 58, 61, 62, 63, 65, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 85, 86, 87, 88, 90, 91, 92, 93, 95, 96, 98
Offset: 0

Views

Author

Alex Ratushnyak, May 15 2016

Keywords

Crossrefs

Programs

  • Mathematica
    Take[#, 66] &@ Union@ Table[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2] &@ IntegerDigits[n, 2], {n, 0, 10^3}] (* Michael De Vlieger, May 17 2016 *)
  • Python
    def ROR(n):                # returns A038572(n)
        BL = len(bin(n))-2
        return (n>>1) + ((n&1) << (BL-1))
    def ROL(n):                # returns A006257(n) for n>0
        BL = len(bin(n))-2
        return (n*2) - (1<
    				

A273180 Numbers n such that ror(n) + rol(n) is a power of 2, where ror(n)=A038572(n) is n rotated one binary place to the right, rol(n)=A006257(n) is n rotated one binary place to the left.

Original entry on oeis.org

1, 2, 6, 19, 38, 102, 307, 614, 1638, 4915, 9830, 26214, 78643, 157286, 419430, 1258291, 2516582, 6710886, 20132659, 40265318, 107374182, 322122547, 644245094, 1717986918, 5153960755, 10307921510, 27487790694, 82463372083, 164926744166, 439804651110
Offset: 1

Views

Author

Alex Ratushnyak, May 17 2016

Keywords

Crossrefs

Programs

  • C
    #include 
    int main(int argc, char** argv)
    {
      unsigned long long x, n, BL=0;
      for (n=1; n>0; ++n) {
        if ((n & (n-1))==0)  ++BL;
        x = (n>>1) + ((n&1) << (BL-1));   // A038572(n)
        x+= (n*2) - (1ull<A006257(n)  for n>0
        if ((x & (x-1))==0)  printf("%lld, ", n);
      }
    }
    
  • Mathematica
    Select[Range[10^6], IntegerQ@ Log2[FromDigits[RotateRight@ #, 2] + FromDigits[RotateLeft@ #, 2]] &@ IntegerDigits[#, 2] &] (* or *)
    Rest@ CoefficientList[Series[x (1 + 2 x + 6 x^2 + 2 x^3 + 4 x^4)/((1 - x) (1 + x + x^2) (1 - 16 x^3)), {x, 0, 30}], x] (* Michael De Vlieger, May 19 2016 *)
  • PARI
    Vec(x*(1+2*x+6*x^2+2*x^3+4*x^4)/((1-x)*(1+x+x^2)*(1-16*x^3)) + O(x^50)) \\ Colin Barker, May 19 2016

Formula

From Colin Barker, May 19 2016: (Start)
a(n) = 17*a(n-3) - 16*a(n-6) for n>6.
G.f.: x*(1+2*x+6*x^2+2*x^3+4*x^4) / ((1-x)*(1+x+x^2)*(1-16*x^3)).
(End)

A274524 Numbers n such that both ror(n) and rol(n) are squares, where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left.

Original entry on oeis.org

1, 2, 8, 32, 128, 512, 1568, 2048, 2312, 2592, 2888, 8192, 16928, 32768, 131072, 139392, 250632, 524288, 549152, 566048, 672800, 924800, 963272, 1318688, 2097152, 8388608, 8520192, 8769672, 9005768, 12261152, 13582472, 15635232, 33554432, 134217728, 136059008, 136587392
Offset: 1

Views

Author

Alex Ratushnyak, Jun 27 2016

Keywords

Comments

A004171 and A081294 are subsequences.
From Robert Israel, Jul 13 2016: (Start)
All terms except 1 are even.
Even terms are the numbers of the form n = (a+b)^2/8 such that for some d >= 1,
2^d <= n < 2^(d+1) and 2^(d+1)-1 = a*b. (End)

Crossrefs

Programs

  • Maple
    F:= proc(d) local v,R,X;
          v:= 2^(d+1)-1;
          R:= select(t-> t^2 < v,numtheory:-divisors(v));
          op(select(t -> t >= (v+1)/2 and t < v+1, map(t -> (t+ v/t)^2/8, R)));
    end proc:
    sort(convert({1,seq(F(i),i=1..50)},list)); # Robert Israel, Jul 13 2016
  • Mathematica
    Select[Range[10^6], Times @ Boole@ {IntegerQ@ Sqrt@ FromDigits[RotateRight@ #, 2], IntegerQ@ Sqrt@ FromDigits[RotateLeft@ #, 2]} &@ IntegerDigits[#, 2] == 1 &] (* Michael De Vlieger, Jun 29 2016 *)

A273050 Numbers k such that ror(k) XOR rol(k) = k, where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left, and XOR is the binary exclusive-or operator.

Original entry on oeis.org

0, 5, 6, 45, 54, 365, 438, 2925, 3510, 23405, 28086, 187245, 224694, 1497965, 1797558, 11983725, 14380470, 95869805, 115043766, 766958445, 920350134, 6135667565, 7362801078, 49085340525, 58902408630, 392682724205, 471219269046
Offset: 1

Views

Author

Alex Ratushnyak, May 13 2016

Keywords

Crossrefs

Cf. A006257, A038572, A088163, A125836 (bisection?), A125837 (bisection?).
Cf. A020988 (numbers k such that ror(k) + rol(k) = k).

Programs

  • Mathematica
    ok[n_] := Block[{x = IntegerDigits[n, 2]}, x == BitXor @@@ Transpose@ {RotateLeft@ x, RotateRight@ x}]; Select[ Range[0, 10^5], ok] (* Giovanni Resta, May 14 2016 *)
    ok[n_] := Block[{x = IntegerDigits[n, 2]}, x == BitXor @@@ Transpose[ {RotateLeft[x], RotateRight[x]}]]; Select[LinearRecurrence[{0, 9, 0, -8}, {0, 5, 6, 45}, 100], ok] (* Jean-François Alcover, May 22 2016, after Giovanni Resta *)
  • Python
    def ROR(n):                # returns A038572(n)
        BL = len(bin(n))-2
        return (n>>1) + ((n&1) << (BL-1))
    def ROL(n):                # returns A006257(n) for n>0
        BL = len(bin(n))-2
        return (n*2) - (1<
    				

Formula

Conjectures from Colin Barker, May 22 2016: (Start)
a(n) = (-11+(-1)^n+2^(-1/2+(3*n)/2)*(3-3*(-1)^n+5*sqrt(2)+5*(-1)^n*sqrt(2)))/14.
a(n) = 5*(2^(3*n/2)-1)/7 for n even.
a(n) = 3*(2^((3*n)/2-1/2)-2)/7 for n odd.
a(n) = 9*a(n-2)-8*a(n-4) for n>4.
G.f.: x^2*(5+6*x) / ((1-x)*(1+x)*(1-8*x^2)).
(End)

Extensions

a(19)-a(27) from Giovanni Resta, May 14 2016

A274133 Numbers representable as ror(x)+rol(x) in two or more ways, where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left.

Original entry on oeis.org

2, 9, 14, 15, 20, 27, 32, 37, 42, 47, 52, 57, 62, 129, 134, 139, 144, 149, 154, 159, 164, 169, 174, 179, 184, 189, 194, 195, 199, 200, 204, 205, 209, 210, 214, 215, 219, 220, 224, 225, 229, 230, 234, 235, 239, 240, 244, 245, 249, 250, 254, 255, 260, 265, 270, 275
Offset: 1

Views

Author

Alex Ratushnyak, Jun 10 2016

Keywords

Comments

These are the duplicates in A273105.

Examples

			ror(5) + rol(5) = 6 + 3 = 9, and also ror(16) + rol(16) = 8 + 1 = 9, therefore 9 is in the sequence.
		

Crossrefs

A274134 Primes p such that both ror(p) and rol(p) are also primes, where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left.

Original entry on oeis.org

3, 7, 11, 31, 43, 67, 79, 127, 131, 139, 167, 191, 211, 223, 227, 307, 331, 367, 487, 523, 631, 691, 743, 751, 883, 971, 1039, 1087, 1399, 2063, 2083, 2143, 2179, 2239, 2267, 2287, 2347, 2411, 2423, 2503, 2531, 2543, 2591, 2687, 2731, 2803, 2819, 2927, 2939, 2963
Offset: 1

Views

Author

Alex Ratushnyak, Jun 10 2016

Keywords

Comments

a(n) mod 4 = 3.

Crossrefs

Programs

  • Mathematica
    Select[Prime@ Range@ 430, And[PrimeQ@ FromDigits[RotateLeft@ #, 2], PrimeQ@ FromDigits[RotateRight@ #, 2]] &@ IntegerDigits[#, 2] &] (* Michael De Vlieger, Jun 22 2016 *)
  • Python
    from sympy import isprime
    for n in range(3, 10000, 2):
        if not isprime(n): continue
        BL = len(bin(n))-2
        x = (n>>1) + ((n&1) << (BL-1))   # A038572(n)
        if not isprime(x): continue
        y = (n*2) - (1<A006257(n)  for n>0
        if not isprime(y): continue
        print(str(n), end=', ')

A274341 Numbers that cannot be represented as ror(x)+rol(x), where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left.

Original entry on oeis.org

1, 4, 7, 11, 12, 13, 16, 18, 21, 23, 26, 28, 31, 35, 36, 40, 41, 45, 46, 49, 50, 54, 55, 59, 60, 64, 69, 74, 79, 84, 89, 94, 97, 102, 107, 112, 117, 122, 127, 131, 132, 136, 137, 141, 142, 146, 147, 151, 152, 156, 157, 161, 162, 166, 167, 171, 172, 176, 177, 181
Offset: 1

Views

Author

Alex Ratushnyak, Jun 26 2016

Keywords

Comments

Numbers that are not in A273105.

Crossrefs

A001969 Evil numbers: nonnegative integers with an even number of 1's in their binary expansion.

Original entry on oeis.org

0, 3, 5, 6, 9, 10, 12, 15, 17, 18, 20, 23, 24, 27, 29, 30, 33, 34, 36, 39, 40, 43, 45, 46, 48, 51, 53, 54, 57, 58, 60, 63, 65, 66, 68, 71, 72, 75, 77, 78, 80, 83, 85, 86, 89, 90, 92, 95, 96, 99, 101, 102, 105, 106, 108, 111, 113, 114, 116, 119, 120, 123, 125, 126, 129
Offset: 1

Views

Author

Keywords

Comments

This sequence and A000069 give the unique solution to the problem of splitting the nonnegative integers into two classes in such a way that sums of pairs of distinct elements from either class occur with the same multiplicities [Lambek and Moser]. Cf. A000028, A000379.
In French: les nombres païens.
Theorem: First differences give A036585. (Observed by Franklin T. Adams-Watters.)
Proof from Max Alekseyev, Aug 30 2006 (edited by N. J. A. Sloane, Jan 05 2021): (Start)
Observe that if the last bit of a(n) is deleted, we get the nonnegative numbers 0, 1, 2, 3, ... in order.
The last bit in a(n+1) is 1 iff the number of bits in n is odd, that is, iff A010060(n+1) is 1.
So, taking into account the different offsets here and in A010060, we have a(n) = 2*(n-1) + A010060(n-1).
Therefore the first differences of the present sequence equal 2 + first differences of A010060, which equals A036585. QED (End)
Integers k such that A010060(k-1)=0. - Benoit Cloitre, Nov 15 2003
Indices of zeros in the Thue-Morse sequence A010060 shifted by 1. - Tanya Khovanova, Feb 13 2009
Conjecture, checked up to 10^6: a(n) is also the sequence of numbers k representable as k = ror(x) XOR rol(x) (for some integer x) where ror(x)=A038572(x) is x rotated one binary place to the right, rol(x)=A006257(x) is x rotated one binary place to the left, and XOR is the binary exclusive-or operator. - Alex Ratushnyak, May 14 2016
From Charlie Neder, Oct 07 2018: (Start)
Conjecture is true: ror(x) and rol(x) have an even number of 1 bits in total (= 2 * A000120(x)), and XOR preserves the parity of this total, so the resulting number must have an even number of 1 bits. An x can be constructed corresponding to a(n) like so:
If the number of bits in a(n) is even, add a leading 0 so a(n) is 2k+1 bits long.
Do an inverse shuffle on a(n), then "divide" by 11, rotate the result k bits to the right, and shuffle to get x. (End)
Numbers of the form m XOR (2*m) for some m >= 0. - Rémy Sigrist, Feb 07 2021
The terms "evil numbers" and "odious numbers" were coined by Richard K. Guy, c. 1976 (Haque and Shallit, 2016) and appeared in the book by Berlekamp et al. (Vol. 1, 1st ed., 1982). - Amiram Eldar, Jun 08 2021

References

  • Elwyn R. Berlekamp, John H. Conway, Richard K. Guy, Winning Ways for Your Mathematical Plays, Volume 1, 2nd ed., A K Peters, 2001, chapter 14, p. 110.
  • Hugh L. Montgomery, Ten Lectures on the Interface Between Analytic Number Theory and Harmonic Analysis, Amer. Math. Soc., 1996, p. 208.
  • Donald J. Newman, A Problem Seminar, Springer; see Problem #89.
  • Vladimir S. Shevelev, On some identities connected with the partition of the positive integers with respect to the Morse sequence, Izv. Vuzov of the North-Caucasus region, Nature sciences 4 (1997), 21-23 (Russian).
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Complement of A000069 (the odious numbers). Cf. A133009.
a(n)=2*n+A010060(n)=A000069(n)-(-1)^A010060(n). Cf. A018900.
The basic sequences concerning the binary expansion of n are A000120, A000788, A000069, A001969, A023416, A059015.
Cf. A036585 (differences), A010060, A006364.
For primes see A027699, also A130593.

Programs

  • Haskell
    a001969 n = a001969_list !! (n-1)
    a001969_list = [x | x <- [0..], even $ a000120 x]
    -- Reinhard Zumkeller, Feb 01 2012
    
  • Magma
    [ n : n in [0..129] | IsEven(&+Intseq(n,2)) ]; // Sergei Haller (sergei(AT)sergei-haller.de), Dec 21 2006
    
  • Maple
    s := proc(n) local i,j,ans; ans := [ ]; j := 0; for i from 0 while jA001969 := n->t1[n]; # s(k) gives first k terms.
    # Alternative:
    seq(`if`(add(k, k=convert(n,base,2))::even, n, NULL), n=0..129); # Peter Luschny, Jan 15 2021
    # alternative for use outside this sequence
    isA001969 := proc(n)
        add(d,d=convert(n,base,2)) ;
        type(%,'even') ;
    end proc:
    A001969 := proc(n)
        option remember ;
        local a;
        if n = 0 then
            1;
        else
            for a from procname(n-1)+1 do
                if isA001969(a) then
                    return a;
                end if;
            end do:
        end if;
    end proc:
    seq(A001969(n),n=1..200) ; # R. J. Mathar, Aug 07 2022
  • Mathematica
    Select[Range[0,300], EvenQ[DigitCount[ #, 2][[1]]] &]
    a[ n_] := If[ n < 1, 0, With[{m = n - 1}, 2 m + Mod[-Total@IntegerDigits[m, 2], 2]]]; (* Michael Somos, Jun 09 2019 *)
  • PARI
    a(n)=n-=1; 2*n+subst(Pol(binary(n)),x,1)%2
    
  • PARI
    a(n)=if(n<1,0,if(n%2==0,a(n/2)+n,-a((n-1)/2)+3*n))
    
  • PARI
    a(n)=2*(n-1)+hammingweight(n-1)%2 \\ Charles R Greathouse IV, Mar 22 2013
    
  • Python
    def ok(n): return bin(n)[2:].count('1') % 2 == 0
    print(list(filter(ok, range(130)))) # Michael S. Branicky, Jun 02 2021
    
  • Python
    from itertools import chain, count, islice
    def A001969_gen(): # generator of terms
        return chain((0,),chain.from_iterable((sorted(n^ n<<1 for n in range(2**l,2**(l+1))) for l in count(0))))
    A001969_list = list(islice(A001969_gen(),30)) # Chai Wah Wu, Jun 29 2022
    
  • Python
    def A001969(n): return ((m:=n-1).bit_count()&1)+(m<<1) # Chai Wah Wu, Mar 03 2023

Formula

a(n+1) - A001285(n) = 2n-1 has been verified for n <= 400. - John W. Layman, May 16 2003 [This can be directly verified by comparing Ralf Stephan's formulas for this sequence (see below) and for A001285. - Jianing Song, Nov 04 2024]
Note that 2n+1 is in the sequence iff 2n is not and so this sequence has asymptotic density 1/2. - Franklin T. Adams-Watters, Aug 23 2006
a(n) = (1/2) * (4n - 3 - (-1)^A000120(n-1)). - Ralf Stephan, Sep 14 2003
G.f.: Sum_{k>=0} (t(3+2t+3t^2)/(1-t^2)^2) * Product_{l=0..k-1} (1-x^(2^l)), where t = x^2^k. - Ralf Stephan, Mar 25 2004
a(2*n+1) + a(2*n) = A017101(n-1) = 8*n-5.
a(2*n) - a(2*n-1) gives the Thue-Morse sequence (3, 1 version): 3, 1, 1, 3, 1, 3, 3, 1, 1, 3, .... A001969(n) + A000069(n) = A016813(n-1) = 4*n-3. - Philippe Deléham, Feb 04 2004
a(1) = 0; for n > 1: a(n) = 3*n-3 - a(n/2) if n even, a(n) = a((n+1)/2)+n-1 if n odd.
Let b(n) = 1 if sum of digits of n is even, -1 if it is odd; then Shallit (1985) showed that Product_{n>=0} ((2n+1)/(2n+2))^b(n) = 1/sqrt(2).
a(n) = 2n - 2 + A010060(n-1). - Franklin T. Adams-Watters, Aug 28 2006
A005590(a(n-1)) <= 0. - Reinhard Zumkeller, Apr 11 2012
A106400(a(n-1)) = 1. - Reinhard Zumkeller, Apr 29 2012
a(n) = (a(n-1) + 2) XOR A010060(a(n-1) + 2). - Falk Hüffner, Jan 21 2022
a(n+1) = A006068(n) XOR (2*A006068(n)). - Rémy Sigrist, Apr 14 2022

Extensions

More terms from Robin Trew (trew(AT)hcs.harvard.edu)
Showing 1-10 of 31 results. Next