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 10 results.

A227741 Simple self-inverse permutation of natural numbers: List each block of A005811(n) numbers from A173318(n-1)+1 to A173318(n) in reverse order.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Comments

This permutation maps between such irregular tables as A101211 and A227736 which are otherwise identical, except for the order in which the lengths of runs have been listed. In other words, A227736(n) = A101211(a(n)) and vice versa, A101211(n) = A227736(a(n)).

Crossrefs

Cf. A227742 (gives the fixed points).

Programs

Formula

a(n) = A173318(A227737(n)) - A227740(n).

A227743 Integers n for which A173318(n) is a square.

Original entry on oeis.org

0, 1, 3, 5, 47, 54, 79, 85, 92, 102, 111, 155, 165, 196, 209, 220, 255, 284, 297, 346, 373, 464, 511, 533, 745, 842, 1039, 1066, 1210, 1358, 1505, 1540, 1577, 1728, 1796, 1947, 2196, 3034, 3087, 3615, 3974, 4036, 4113, 4372, 4740, 5050, 5107, 5632, 5870, 6159
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Crossrefs

Cf. A227744 (gives the corresponding squares), A227745.

A227744 Squares that occur in A173318.

Original entry on oeis.org

0, 1, 4, 9, 144, 169, 256, 289, 324, 361, 400, 576, 625, 784, 841, 900, 1024, 1156, 1225, 1521, 1681, 2116, 2304, 2401, 3721, 4225, 5184, 5329, 6241, 7225, 8281, 8464, 8649, 9604, 10000, 10816, 12100, 18225, 18496, 21904, 24025, 24336, 24649, 26244, 28900, 31329
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013, proposed by Jonathan Vos Post in Comments section of A173318

Keywords

Crossrefs

Cf. A227745 (gives the square roots of these terms).
All values A096033(n)*(2^(A096033(n)-1)) occur here. - Antti Karttunen, Jul 29 2013

Programs

  • Mathematica
    seq = {0}; n = 0; s = 0; While[Length[seq] < 100,
    s += Length[Length /@ Split[IntegerDigits[++n, 2]]]; If[IntegerQ@ Sqrt@ s, AppendTo[seq, s]]]; seq (* Giovanni Resta, Jul 27 2013 *)
  • Scheme
    (define (A227744 n) (A173318 (A227743 n)))

Formula

a(n) = A173318(A227743(n)).

A227745 Nonnegative integers whose squares occur in A173318.

Original entry on oeis.org

0, 1, 2, 3, 12, 13, 16, 17, 18, 19, 20, 24, 25, 28, 29, 30, 32, 34, 35, 39, 41, 46, 48, 49, 61, 65, 72, 73, 79, 85, 91, 92, 93, 98, 100, 104, 110, 135, 136, 148, 155, 156, 157, 162, 170, 177, 178, 190, 195, 200, 206, 207, 208, 209, 213, 214, 226, 228, 247, 248
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Crossrefs

Programs

  • Mathematica
    Select[Sqrt[#]&/@Accumulate[Join[{0},Table[Length[Split[IntegerDigits[n,2]]],{n,10000}]]],IntegerQ] (* Harvey P. Dale, Nov 20 2022 *)
  • Scheme
    (define (A227745 n) (sqrt (A227744 n)))

Formula

a(n) = sqrt(A227744(n)).

A005811 Number of runs in binary expansion of n (n>0); number of 1's in Gray code for n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Starting with a(1) = 0 mirror all initial 2^k segments and increase by one.
a(n) gives the net rotation (measured in right angles) after taking n steps along a dragon curve. - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
This sequence generates A082410: (0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, ...) and A014577; identical to the latter except starting 1, 1, 0, ...; by writing a "1" if a(n+1) > a(n); if not, write "0". E.g., A014577(2) = 0, since a(3) < a(2), or 1 < 2. - Gary W. Adamson, Sep 20 2003
Starting with 1 = partial sums of A034947: (1, 1, -1, 1, 1, -1, -1, 1, 1, 1, ...). - Gary W. Adamson, Jul 23 2008
The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.
Can be used as a binomial transform operator: Let a(n) = the n-th term in any S(n); then extract 2^k strings, adding the terms. This results in the binomial transform of S(n). Say S(n) = 1, 3, 5, ...; then we obtain the strings: (1), (3, 1), (3, 5, 3, 1), (3, 5, 7, 5, 3, 5, 3, 1), ...; = the binomial transform of (1, 3, 5, ...) = (1, 4, 12, 32, 80, ...). Example: the 8-bit string has a sum of 32 with a distribution of (1, 3, 3, 1) or one 1, three 3's, three 5's, and one 7; as expected. - Gary W. Adamson, Jun 21 2012
Considers all positive odd numbers as nodes of a graph. Two nodes are connected if and only if the sum of the two corresponding odd numbers is a power of 2. Then a(n) is the distance between 2n + 1 and 1. - Jianing Song, Apr 20 2019

Examples

			Considered as a triangle with 2^k terms per row, the first few rows are:
  1
  2, 1
  2, 3, 2, 1
  2, 3, 4, 3, 2, 3, 2, 1
  ...
The n-th row becomes right half of next row; left half is mirrored terms of n-th row increased by one. - _Gary W. Adamson_, Jun 20 2012
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A037834 (-1), A088748 (+1), A246960 (mod 4), A034947 (first differences), A000975 (indices of record highs), A173318 (partial sums).
Partial sums of A112347. Recursion depth of A035327.

Programs

  • Haskell
    import Data.List (group)
    a005811 0 = 0
    a005811 n = length $ group $ a030308_row n
    a005811_list = 0 : f [1] where
       f (x:xs) = x : f (xs ++ [x + x `mod` 2, x + 1 - x `mod` 2])
    -- Reinhard Zumkeller, Feb 16 2013, Mar 07 2011
    
  • Maple
    A005811 := proc(n)
        local i, b, ans;
        if n = 0 then
            return 0 ;
        end if;
        ans := 1;
        b := convert(n, base, 2);
        for i from nops(b)-1 to 1 by -1 do
            if b[ i+1 ]<>b[ i ] then
                ans := ans+1
            fi
        od;
        return ans ;
    end proc:
    seq(A005811(i), i=1..50) ;
    # second Maple program:
    a:= n-> add(i, i=Bits[Split](Bits[Xor](n, iquo(n, 2)))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Feb 01 2023
  • Mathematica
    Table[ Length[ Length/@Split[ IntegerDigits[ n, 2 ] ] ], {n, 1, 255} ]
    a[n_] := DigitCount[BitXor[n, Floor[n/2]], 2, 1]; Array[a, 100, 0] (* Amiram Eldar, Jul 11 2024 *)
  • PARI
    a(n)=sum(k=1,n,(-1)^((k/2^valuation(k,2)-1)/2))
    
  • PARI
    a(n)=if(n<1,0,a(n\2)+(a(n\2)+n)%2) \\ Benoit Cloitre, Jan 20 2014
    
  • PARI
    a(n) = hammingweight(bitxor(n, n>>1));  \\ Gheorghe Coserea, Sep 03 2015
    
  • Python
    def a(n): return bin(n^(n>>1))[2:].count("1") # Indranil Ghosh, Apr 29 2017

Formula

a(2^k + i) = a(2^k - i + 1) + 1 for k >= 0 and 0 < i <= 2^k. - Reinhard Zumkeller, Aug 14 2001
a(2n+1) = 2a(n) - a(2n) + 1, a(4n) = a(2n), a(4n+2) = 1 + a(2n+1).
a(j+1) = a(j) + (-1)^A014707(j). - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
G.f.: (1/(1-x)) * Sum_{k>=0} x^2^k/(1+x^2^(k+1)). - Ralf Stephan, May 02 2003
Delete the 0, make subsets of 2^n terms; and reverse the terms in each subset to generate A088696. - Gary W. Adamson, Oct 19 2003
a(0) = 0, a(2n) = a(n) + [n odd], a(2n+1) = a(n) + [n even]. - Ralf Stephan, Oct 20 2003
a(n) = Sum_{k=1..n} (-1)^((k/2^A007814(k)-1)/2) = Sum_{k=1..n} (-1)^A025480(k-1). - Ralf Stephan, Oct 29 2003
a(n) = A069010(n) + A033264(n). - Ralf Stephan, Oct 29 2003
a(0) = 0 then a(n) = a(floor(n/2)) + (a(floor(n/2)) + n) mod 2. - Benoit Cloitre, Jan 20 2014
a(n) = A037834(n) + 1.
a(n) = A000120(A003188(n)). - Amiram Eldar, Jul 11 2024

Extensions

Additional description from Wouter Meeussen

A227183 a(n) is the sum of parts of the unique unordered partition encoded in the run lengths of the binary expansion of n; row sums of A227739 for n >= 1.

Original entry on oeis.org

0, 1, 2, 2, 4, 3, 3, 3, 6, 5, 4, 6, 5, 4, 4, 4, 8, 7, 6, 8, 8, 5, 7, 9, 7, 6, 5, 7, 6, 5, 5, 5, 10, 9, 8, 10, 10, 7, 9, 11, 12, 9, 6, 10, 11, 8, 10, 12, 9, 8, 7, 9, 9, 6, 8, 10, 8, 7, 6, 8, 7, 6, 6, 6, 12, 11, 10, 12, 12, 9, 11, 13, 14, 11, 8, 12, 13, 10, 12, 14
Offset: 0

Views

Author

Antti Karttunen, Jul 05 2013

Keywords

Comments

Like A129594 this sequence utilizes the fact that compositions (i.e., ordered partitions) can be bijectively mapped to (unordered) partitions by taking the partial sums of the list of composants after one has been subtracted from each except the first one. Compositions in turn are mapped to nonnegative integers via the runlength encoding, where the lengths of maximum runs of 0's or 1's in binary representation of n give the composants. See the OEIS Wiki page and the example below.
Each n occurs A000041(n) times in total and occurs for the first time at A227368(n) and for the last time at position A000225(n). See further comments and conjectures at A227368 and A227370.

Examples

			19 has binary expansion "10011", thus the maximal runs of identical bits (scanned from right to left) are [2,2,1]. We subtract one from each after the first one, to get [2,1,0] and then form their partial sums as [2,2+1,2+1+0], which thus maps to unordered partition {2+3+3} which adds to 8. Thus a(19)=8.
		

Crossrefs

Row sums of A227189 and A227739. Cf. A227184 (corresponding products), A227185, A227189, A227192, A129594, A226062, A227368.
Analogous sum sequences computed for other encoding schemes of unordered partitions: A036042, A056239, A161511, A243503. Cf. also A229119, A003188, A075157, A243353 (associated permutations mapping between these schemes).

Programs

  • Mathematica
    Table[Function[b, Total@ Accumulate@ Prepend[If[Length@ b > 1, Rest[b] - 1, {}], First@ b] - Boole[n == 0]]@ Map[Length, Split@ Reverse@ IntegerDigits[n, 2]], {n, 0, 79}] // Flatten (* Michael De Vlieger, May 09 2017 *)
  • Python
    def A227183(n):
      '''Sum of parts of the unique unordered partition encoded in the run lengths of the binary expansion of n.'''
      s = 0
      b = n%2
      i = 1
      while (n != 0):
        n >>= 1
        if ((n%2) == b): # Staying in the same run of bits?
          i += 1
        else: # The run changes.
          b = n%2
          s += i
      return(s)

Formula

a(n) = Sum_{i=0..A005811(n)-1} A227189(n,i). [The defining formula]
Equivalently, for n>=1, a(n) = Sum_{i=(A173318(n-1)+1)..A173318(n)} A227739(i).
a(n) = A227192(n) - A000217(A005811(n)-1).
Other identities:
a(A129594(n)) = a(n). [This follows from the fact that conjugating a partition doesn't change its total sum]
a(A226062(n)) = a(n). [Which is also true for the "Bulgarian operation"]
From Antti Karttunen, Mar 08 2015: (Start)
Can be also obtained by mapping with an appropriate permutation from the sequences giving sizes of each partition (i.e., sum of their parts) computed for other enumerations similar to A227739:
a(n) = A036042(A229119(n)).
a(n) = A161511(A003188(n)).
a(n) = A056239(A243353(n)).
a(n) = A243503(1+A075157(n)).
(End)

A227737 n occurs as many times as there are runs in binary representation of n.

Original entry on oeis.org

1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, 24, 25, 25, 25, 26, 26, 26, 26
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Comments

a(n) = the least integer k such that A173318(k) >= n, which implies that each n occurs A005811(n) times.
Although as such quite uninteresting, this sequence is useful for computing irregular tables like A101211, A227736, A227738 and A227739.

Examples

			1 has one run in its binary representation "1", thus 1 occurs once.
2 has two runs in its binary representation "10", thus 2 occurs twice.
3 has one run in its binary representation "11", thus 3 occurs only once.
4 has two runs in its binary representation "100", thus 4 occurs twice.
5 has three runs in its binary representation "101", thus 5 occurs three times.
The sequence thus begins as 1, 2,2, 3, 4,4, 5,5,5, ...
		

Crossrefs

Programs

  • Mathematica
    Table[ConstantArray[n, Length@ Split@ IntegerDigits[n, 2]], {n, 26}] // Flatten (* Michael De Vlieger, May 09 2017 *)
    Table[PadRight[{},Length[Split[IntegerDigits[n,2]]],n],{n,40}]//Flatten (* Harvey P. Dale, Jul 23 2021 *)

A227740 Integers from 0 to A037834(n) followed by integers from 0 to A037834(n+1) and so on.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Comments

Equivalently, integers from 0 to A005811(n)-1 followed by integers from 0 to A005811(n+1)-1 and so on.

Crossrefs

Programs

  • Mathematica
    Table[Range[0, #] &@ Total@ Flatten@ Map[Abs@ Differences@ # &,
    Partition[IntegerDigits[n, 2], 2, 1]], {n, 34}] // Flatten (* Michael De Vlieger, May 09 2017 *)
  • Scheme
    (define (A227740 n) (- n (+ 1 (A173318 (- (A227737 n) 1)))))

Formula

a(n) = n - (1 + A173318(A227737(n)-1)).

A227192 Sum of the partial sums of the run lengths of binary expansion of n, when starting scanning from the least significant end; Row sums of A227188 and A227738.

Original entry on oeis.org

1, 3, 2, 5, 6, 4, 3, 7, 8, 10, 9, 6, 7, 5, 4, 9, 10, 12, 11, 14, 15, 13, 12, 8, 9, 11, 10, 7, 8, 6, 5, 11, 12, 14, 13, 16, 17, 15, 14, 18, 19, 21, 20, 17, 18, 16, 15, 10, 11, 13, 12, 15, 16, 14, 13, 9, 10, 12, 11, 8, 9, 7, 6, 13, 14, 16, 15, 18, 19, 17, 16
Offset: 1

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

Equivalently, sum of bit-indices in binary expansion of n (counted from the right hand end, with the least significant bit having bit-index 0) of the positions where a bit differs from its immediate right-hand neighbor, counted up to the first leading zero.
a(0) could be 0 or 1, depending on how the binary expansion of zero is conceived, thus its value is left unspecified here.
From Jason Kimberley, Feb 22 2022: (Start)
Also, the total length of string movement required to display the binary expansion of n by the positions of the vanes of vertical blinds (starting with all 0).
The transitions from 0000 to 1011 are:
0001, 0011, 0111, 1111;
1110, 1100, 1000;
The transitions from 0000 to 1101 are:
0001, 0011, 0111, 1111;
1110, 1100;
1101. (End)

Examples

			For 11, whose binary expansion is "1011", the run lengths, when starting scanning from the right, are: [2,1,1]. Their partial sums are [2,2+1,2+1+1] = [2,3,4] which sum to total 9, thus a(11)=9. Equivalently, the zero-based positions (counted from the right) where bits change from one to zero or vice versa in "...01011" are 2, 3, 4 and 2+3+4 = 9.
For 13, whose binary expansion is "1101", the run lengths similarly scanned are [1,1,2]. Their partial sums are [1,1+1,1+1+2] = [1,2,4] which sum to total 7, thus a(13)=7. Equivalently, the positions where bits change in "...01101" are 1, 2, 4 and 1+2+4 = 7.
		

Crossrefs

Cf. A005811, A227183. Row sums of A227188 and A227738.

Programs

  • Mathematica
    Table[Tr[FoldList[Plus,0,Length /@ Split[Reverse[IntegerDigits[n,2]]]] ],{n,71}] (* Wouter Meeussen, Aug 22 2013 *)
  • PARI
    a(n)=local(b,s,t);b=binary(n);s=#b;t=b[#b];forstep(i=#b-1,1,-1,if(b[i]!=t,s=s+#b-i;t=!t));s /* Ralf Stephan, Sep 04 2013 */
    
  • Python
    def A227192(n):
      '''Sum of the partial sums of the run lengths of binary expansion of n, starting from the least significant end.'''
      s = 0
      b = n%2
      i = 0
      while (n != 0):
        n >>= 1
        i += 1
        if((n%2) != b):
          b = n%2
          s += i
      return(s)
    
  • Ruby
    def a(n)
      k = n.to_s(2).scan(/((\d)\2*)/)
      k.each_index.map { |i| (i + 1) * k[i][0].size }.reduce(:+)
    end # Peter Kagey, Aug 06 2015
  • Scheme
    (define (A227192 n) (let loop ((i (- (A005811 n) 1)) (s 0)) (cond ((< i 0) s) (else (loop (- i 1) (+ s (A227188bi n i))))))) ;; This version sums the nonzero terms of the n-th row of table A227188.
    (define (A227192v2 n) (+ (A227183 n) (A000217 (- (A005811 n) 1)))) ;; Another variant.
    (define (A227192v3 n) (add A227738 (+ 1 (A173318 (- n 1))) (A173318 n))) ;; This sums terms of table A227738.
    ;; With the help of this function that implements Sum_{i=lowlim..uplim} intfun(i)
    (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
    

Formula

a(n) = Sum_{i=0..A005811(n)-1} A227188(n,i). [Row sums of A227188]
Equivalently, for n>=1, a(n) = Sum_{i=(A173318(n-1)+1)..A173318(n)} A227738(i). [Row sums of A227738]
a(n) = A227183(n) + A000217(A005811(n)-1). [Alternative definition]
a(n) = A029931(A003188(n)).
Recurrence: a(2n) = a(n) + 2*A069010(n), a(2n+1) = a(2n) +1 or -1, according to if n is even or odd. - Ralf Stephan, Sep 04 2013

A227742 Fixed points of permutation A227741.

Original entry on oeis.org

1, 4, 8, 12, 16, 23, 28, 32, 36, 43, 51, 59, 64, 71, 76, 80, 84, 91, 99, 107, 115, 126, 135, 143, 148, 155, 163, 171, 176, 183, 188, 192, 196, 203, 211, 219, 227, 238, 247, 255, 263, 274, 286, 298, 307, 318, 327, 335, 340, 347, 355, 363, 371, 382, 391, 399, 404
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Programs

Formula

a(n) = A173318(2*(n-1)) + (1/2)*(1 + A005811((2n)-1)).
Showing 1-10 of 10 results.