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 41-50 of 64 results. Next

A355654 For any number n with runs in binary expansion (r_w, ..., r_0), let p(n) be the polynomial of a single indeterminate x where the coefficient of x^e is r_e for e = 0..w and otherwise 0, and let q be the inverse of p; a(n) = q(p(n)^2).

Original entry on oeis.org

0, 1, 9, 15, 271, 313, 481, 511, 33279, 34785, 39993, 40719, 61455, 61689, 65409, 65535, 16842751, 17039233, 17809657, 17821711, 20455183, 20479033, 20842465, 20939263, 31457791, 31465441, 31584313, 31588111, 33488911, 33489913, 33553921, 33554431, 34393292799
Offset: 0

Views

Author

Rémy Sigrist, Jul 12 2022

Keywords

Comments

In other words, a(n) encodes the square of the polynomial encoded by n.

Examples

			The first terms, alongside their binary expansions and corresponding polynomials, are:
  n  a(n)   bin(n)  bin(a(n))         p(n)           p(a(n))
  -  -----  ------  ----------------  -------------  -----------------------------
  0      0       0                 0              0                              0
  1      1       1                 1              1                              1
  2      9      10              1001          x + 1                  x^2 + 2*x + 1
  3     15      11              1111              2                              4
  4    271     100         100001111          x + 2                  x^2 + 4*x + 4
  5    313     101         100111001    x^2 + x + 1  x^4 + 2*x^3 + 3*x^2 + 2*x + 1
  6    481     110         111100001        2*x + 1                4*x^2 + 4*x + 1
  7    511     111         111111111              3                              9
  8  33279    1000  1000000111111111          x + 3                  x^2 + 6*x + 9
  9  34785    1001  1000011111100001  x^2 + 2*x + 1  x^4 + 4*x^3 + 6*x^2 + 4*x + 1
		

Crossrefs

Programs

  • PARI
    toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); r }
    fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
    a(n) = { fromruns(Vec(Pol(toruns(n))^2)) }

Formula

A005811(a(n)) = 2*A005811(n) - 1 for any n > 0.
a(2^n - 1) = 2^(n^2) - 1.

A372538 Numbers k such that the number of ones minus the number of zeros in the binary expansion of the k-th prime number is 1.

Original entry on oeis.org

3, 8, 20, 23, 24, 26, 30, 58, 61, 63, 65, 67, 78, 80, 81, 82, 84, 88, 185, 187, 194, 200, 201, 203, 213, 214, 215, 221, 225, 226, 227, 234, 237, 246, 249, 253, 255, 256, 257, 259, 266, 270, 280, 284, 287, 290, 573, 578, 586, 588, 591, 593, 611, 614, 615, 626
Offset: 1

Views

Author

Gus Wiseman, May 13 2024

Keywords

Examples

			The binary expansion of 83 is (1,0,1,0,0,1,1) with ones minus zeros 4 - 3 = 1, and 83 is the 23rd prime, so 23 is in the sequence.
The primes A000040(a(n)) together with their binary expansions and binary indices begin:
     5:           101 ~ {1,3}
    19:         10011 ~ {1,2,5}
    71:       1000111 ~ {1,2,3,7}
    83:       1010011 ~ {1,2,5,7}
    89:       1011001 ~ {1,4,5,7}
   101:       1100101 ~ {1,3,6,7}
   113:       1110001 ~ {1,5,6,7}
   271:     100001111 ~ {1,2,3,4,9}
   283:     100011011 ~ {1,2,4,5,9}
   307:     100110011 ~ {1,2,5,6,9}
   313:     100111001 ~ {1,4,5,6,9}
   331:     101001011 ~ {1,2,4,7,9}
   397:     110001101 ~ {1,3,4,8,9}
   409:     110011001 ~ {1,4,5,8,9}
   419:     110100011 ~ {1,2,6,8,9}
   421:     110100101 ~ {1,3,6,8,9}
   433:     110110001 ~ {1,5,6,8,9}
   457:     111001001 ~ {1,4,7,8,9}
  1103:   10001001111 ~ {1,2,3,4,7,11}
  1117:   10001011101 ~ {1,3,4,5,7,11}
  1181:   10010011101 ~ {1,3,4,5,8,11}
  1223:   10011000111 ~ {1,2,3,7,8,11}
		

Crossrefs

Restriction of A031448 to the primes, positions of ones in A145037.
Taking primes gives A095073, negative A095072.
Positions of ones in A372516, absolute value A177718.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A030190 gives binary expansion, reversed A030308.
A035103 counts zeros in binary expansion of primes, firsts A372474.
A048793 lists binary indices, reverse A272020, sum A029931.
A070939 gives the length of an integer's binary expansion.
A101211 lists run-lengths in binary expansion, row-lengths A069010.
A372471 lists binary indices of primes.

Programs

  • Mathematica
    Select[Range[1000],DigitCount[Prime[#],2,1]-DigitCount[Prime[#],2,0]==1&]

A372539 Numbers k such that the number of ones minus the number of zeros in the binary expansion of the k-th prime number is -1.

Original entry on oeis.org

7, 19, 21, 25, 56, 57, 59, 60, 62, 68, 71, 77, 79, 87, 175, 177, 179, 180, 186, 188, 189, 192, 193, 195, 196, 197, 204, 210, 212, 216, 218, 243, 244, 248, 254, 262, 263, 265, 279, 567, 572, 576, 577, 583, 592, 598, 599, 600, 602, 603, 605, 606, 610, 613, 616
Offset: 1

Views

Author

Gus Wiseman, May 14 2024

Keywords

Examples

			The binary expansion of 17 is (1,0,0,0,1) with ones minus zeros 2 - 3 = -1, and 17 is the 7th prime, 7 is in the sequence.
The primes A000040(a(n)) together with their binary expansions and binary indices begin:
    17:         10001 ~ {1,5}
    67:       1000011 ~ {1,2,7}
    73:       1001001 ~ {1,4,7}
    97:       1100001 ~ {1,6,7}
   263:     100000111 ~ {1,2,3,9}
   269:     100001101 ~ {1,3,4,9}
   277:     100010101 ~ {1,3,5,9}
   281:     100011001 ~ {1,4,5,9}
   293:     100100101 ~ {1,3,6,9}
   337:     101010001 ~ {1,5,7,9}
   353:     101100001 ~ {1,6,7,9}
   389:     110000101 ~ {1,3,8,9}
   401:     110010001 ~ {1,5,8,9}
   449:     111000001 ~ {1,7,8,9}
  1039:   10000001111 ~ {1,2,3,4,11}
  1051:   10000011011 ~ {1,2,4,5,11}
  1063:   10000100111 ~ {1,2,3,6,11}
  1069:   10000101101 ~ {1,3,4,6,11}
  1109:   10001010101 ~ {1,3,5,7,11}
  1123:   10001100011 ~ {1,2,6,7,11}
  1129:   10001101001 ~ {1,4,6,7,11}
  1163:   10010001011 ~ {1,2,4,8,11}
		

Crossrefs

Restriction of A031444 (positions of '-1's in A145037) to A000040.
Taking primes gives A095072.
Positions of negative ones in A372516, absolute value A177718.
The negative version is A372538, taking primes A095073.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A030190 gives binary expansion, reversed A030308.
A035103 counts zeros in binary expansion of primes, firsts A372474.
A048793 lists binary indices, reverse A272020, sum A029931.
A070939 gives the length of an integer's binary expansion.
A101211 lists run-lengths in binary expansion, row-lengths A069010.
A372471 lists binary indices of primes.

Programs

  • Mathematica
    Select[Range[1000],DigitCount[Prime[#],2,1]-DigitCount[Prime[#],2,0]==-1&]

A165317 a(n) = the number of digits in the binary representation of n that each do not precede or follow a similarly valued digit.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Sep 14 2009

Keywords

Comments

A165316(n) + a(n) = the number of digits in the binary representation of n.
Also number of parts equal to 1 in the composition having index n. For the definition of the index of a composition see A298644. For example, a(18) = 3 since the binary form of 18 is (1)00(1)(0) which has 3 runs of length 1 (each placed between parentheses). The command c(n) from the Maple program yields the composition having index n. - Emeric Deutsch, Jan 29 2018

Examples

			184 in binary is 10111001. There are exactly three binary digits (the first and last 1's, and the leftmost 0) that are each not adjacent to a similar digit. So a(184) = 3.
		

Crossrefs

Programs

  • Maple
    Runs := proc (L) local j, r, i, k: j := 1: r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: a := proc (n) local ct, j: ct := 0: for j to nops(c(n)) do if c(n)[j] = 1 then ct := ct+1 else end if end do: ct end proc: seq(a(n), n = 1 .. 105); # most of the Maple program is due to W. Edwin Clark. # Emeric Deutsch, Jan 29 2018
  • Python
    def a(n): return ((n^(n<<1))&(n^(n>>1))).bit_count() + ((n&3)==2)
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, May 12 2024

Extensions

Extended by Ray Chandler, Mar 13 2010

A175872 Write n in binary. Consider the 0's and 1 as a list. (*) If the new list consists entirely of 1's, then a(n) = the number of 1's, and end. Otherwise, construct a new list made up of the lengths, written in order, of the runs of similarly-valued terms from the previous list. Go to *.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Oct 03 2010

Keywords

Comments

n appears for the first time at A000975(n). - Sean A. Irvine and N. J. A. Sloane, Dec 02 2010
A217921(n) = number of steps needed to calculate a(n). - Reinhard Zumkeller, Mar 26 2013

Examples

			100 (decimal) in binary is 1100100. The lengths of the runs are: 2,2,1,2. The lengths of the runs in the latest list are: 2,1,1. The lengths of the runs in the latest list are: 1,2. The lengths of the runs in the latest list are: 1,1. This last list consists entirely of 1's. There are two 1's, so a(100) = 2.
		

Crossrefs

Programs

  • Haskell
    import Data.List (group, genericLength)
    a175872 = f . a030308_row where
       f xs | all (== 1) xs = length xs
            | otherwise     = f $ map genericLength $ group xs
    -- Reinhard Zumkeller, Mar 26 2013
  • Mathematica
    f[n_Integer] := IntegerDigits[n, 2]; f[nn:{1..}] := nn; f[nn_List] := Length /@ Split[nn]; a[n_] := FixedPoint[f, n] // Length; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Nov 26 2013 *)

Extensions

a(3) corrected by Leroy Quet, Oct 06 2010
More terms from Sean A. Irvine, Dec 02 2010

A336962 Right-rotate run-lengths of consecutive equal digits in binary representation of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Aug 09 2020

Keywords

Comments

This sequence is a permutation of the nonnegative integers, with inverse A336963.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2      10         10
   3     3      11         11
   4     6     100        110
   5     5     101        101
   6     4     110        100
   7     7     111        111
   8    14    1000       1110
   9    11    1001       1011
  10    10    1010       1010
  11    13    1011       1101
  12    12    1100       1100
  13     9    1101       1001
  14     8    1110       1000
  15    15    1111       1111
		

Crossrefs

Programs

  • PARI
    toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2,2)); n\=2^v; r=concat(v,r)); r }
    fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
    a(n) = { my (r=toruns(n)); fromruns(vector(#r, k, r[1+(k-2)%#r])) }

Formula

a(n) = n iff n = 0 or n belongs to A140690.

A336963 Left-rotate run-lengths of consecutive equal digits in binary representation of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Aug 09 2020

Keywords

Comments

This sequence is a permutation of the nonnegative integers, with inverse A336962.

Examples

			The first terms, in decimal and in binary, are:
  n   a(n)  bin(n)  bin(a(n))
  --  ----  ------  ---------
   0     0       0          0
   1     1       1          1
   2     2      10         10
   3     3      11         11
   4     6     100        110
   5     5     101        101
   6     4     110        100
   7     7     111        111
   8    14    1000       1110
   9    13    1001       1101
  10    10    1010       1010
  11     9    1011       1001
  12    12    1100       1100
  13    11    1101       1011
  14     8    1110       1000
  15    15    1111       1111
		

Crossrefs

Programs

  • PARI
    toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2,2)); n\=2^v; r=concat(v,r)); r }
    fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
    a(n) = { my (r=toruns(n)); fromruns(vector(#r, k, r[1+k%#r])) }

Formula

a(n) = n iff n = 0 or n belongs to A140690.

A355653 For any number n with runs in binary expansion (r_w, ..., r_0), let p(n) be the polynomial of a single indeterminate x where the coefficient of x^e is r_e for e = 0..w and otherwise 0, and let q be the inverse of p; a(n) = q(p(n)').

Original entry on oeis.org

0, 0, 1, 0, 1, 6, 3, 0, 1, 12, 57, 6, 3, 30, 7, 0, 1, 24, 225, 12, 57, 966, 115, 6, 3, 60, 505, 30, 7, 126, 15, 0, 1, 48, 897, 24, 225, 7686, 451, 12, 57, 1932, 31801, 966, 115, 3870, 231, 6, 3, 120, 2017, 60, 505, 16326, 1011, 30, 7, 252, 4089, 126, 15, 510
Offset: 0

Views

Author

Rémy Sigrist, Jul 12 2022

Keywords

Comments

In other words, a(n) encodes the derivative of the polynomial encoded by n.
For n > 0, the runs in binary expansion of a(n) are (w*r_w, ..., 1*r_1).

Examples

			The first terms, alongside their binary expansions and corresponding polynomials, are:
  n   a(n)  bin(n)  bin(a(n))  p(n)               p(a(n))
  --  ----  ------  ---------  -----------------  ---------------
   0     0       0          0                  0                0
   1     0       1          0                  1                0
   2     1      10          1              x + 1                1
   3     0      11          0                  2                0
   4     1     100          1              x + 2                1
   5     6     101        110        x^2 + x + 1          2*x + 1
   6     3     110         11            2*x + 1                2
   7     0     111          0                  3                0
   8     1    1000          1              x + 3                1
   9    12    1001       1100      x^2 + 2*x + 1          2*x + 2
  10    57    1010     111001  x^3 + x^2 + x + 1  3*x^2 + 2*x + 1
  11     6    1011        110        x^2 + x + 2          2*x + 1
  12     3    1100         11            2*x + 2                2
  13    30    1101      11110      2*x^2 + x + 1          4*x + 1
		

Crossrefs

Programs

  • PARI
    toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); r }
    fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
    a(n) = { fromruns(Vec(deriv(Pol(toruns(n))))) }

Formula

a^A005811(n)(n) = 0 (where a^k denotes the k-th iterate of a).
a(n) = 0 iff n belongs to A000225.
a(n) = 1 iff n = 2^k for some k > 0.
A005811(a(n)) = A005811(n)-1 for any n > 0.

A356352 a(n) = GCD of run lengths in binary expansion of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Oct 15 2022

Keywords

Comments

a(0) = 0 as the GCD of an empty list (we consider here that the binary expansion of 0 has no runs).

Crossrefs

Programs

  • Mathematica
    {0}~Join~Array[GCD @@ Map[Length, Split@ IntegerDigits[#, 2]] &, 104] (* Michael De Vlieger, Oct 17 2022 *)
  • PARI
    a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); gcd(r) }
    
  • Python
    from math import gcd
    from itertools import groupby
    def a(n):
        if n == 0: return 0 # by convention
        return gcd(*(len(list(g)) for k, g in groupby(bin(n)[2:])))
    print([a(n) for n in range(87)]) # Michael S. Branicky, Oct 15 2022

Formula

a(A001196(n)) = 2*a(n).
a(2^k-1) = k for any k >= 0.

A361477 a(n) is the number of integers whose binary expansions have the same multiset of run-lengths as that of n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 13 2023

Keywords

Comments

This sequence has similarities with A090706; here we consider multisets of run-lengths, there multisets of digits in binary expansions.

Examples

			For n = 18:
- the binary expansion of 18 is "10010",
- the corresponding multiset of run-lengths is m = (1, 2, 1, 1),
- m has 4 terms: 3 times "1" and once "2",
- so a(18) = 4! / (3! * 1!) = 4.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (r=[]); while (n, my (v=valuation(n+n%2, 2)); n\=2^v; r=concat(v, r)); my (s=Set(r), f=vector(#s)); for (k=1, #r, f[setsearch(s, r[k])]++); (#r)! / prod(k=1, #f, f[k]!) }
    
  • Python
    from math import factorial, prod
    from itertools import groupby
    from collections import Counter
    def A361477(n): return factorial(len(c:=[len(list(g)) for k, g in groupby(bin(n)[2:])]))//prod(map(factorial,Counter(c).values())) # Chai Wah Wu, Mar 16 2023

Formula

a(n) = 1 iff n = 0 or n belongs to A140690.
Previous Showing 41-50 of 64 results. Next