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 21-25 of 25 results.

A227193 Difference of (product of runlengths of 1-bits) and (product of runlengths of 0-bits) in binary representation of n.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 08 2013

Keywords

Comments

The sequence seems to consist of palindromic subsequences centered around each (2^k)-1 and 2^k (with end points near the terms of A000975), which is easily explained by symmetric pairing of binary expansion of n and its complement.

Crossrefs

Programs

  • Maple
    a:= proc(n) local i, j, m, r, s; m, r, s:= n, 1, 1;
          while m>0 do
            for i from 0 while irem(m, 2, 'h')=0 do m:=h od;
            for j from 0 while irem(m, 2, 'h')=1 do m:=h od;
            r, s:= r*j, s*max(i, 1)
          od; r-s
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Jul 11 2013
  • Mathematica
    a[n_] := With[{s = Split @ IntegerDigits[n, 2]}, Times @@ Length /@ Select[ s, First[#]==1&] - Times @@ Length /@ Select[s , First[#]==0&]]; Table[ a[n], {n, 0, 100}] (* Jean-François Alcover, Feb 28 2016 *)
  • Scheme
    (define (A227193 n) (- (A227349 n) (A227350 n)))

Formula

a(n) = A227349(n) - A227350(n).

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&]

A337319 a(n) = Sum_{i = 1..floor(log_2(n))+1} g(frac(n/2^i)), where g(t) = [0 if t = 0, -1 if 0 < t < 1/2, 1 if t >= 1/2], and where frac(x) denotes the fractional part.

Original entry on oeis.org

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

Views

Author

Christoph B. Kassir, Aug 23 2020

Keywords

Comments

The function a(n) is a measure of how many times n rounds up (assigned value +1), down (assigned value -1), or not at all (assigned value 0) when divided by incremental powers of two (see example below).
For n = 2^k, all divisions give integers (not rounded at all) until n/2^(k+1), which rounds up to 1, and so a(2^k) = 1.
n/2^i shifts the bits of n down so the bit of n at position i-1 (least significant bit as position 0) is immediately below the radix point and so determines whether frac(n/2^i) >= 1/2 or < 1/2. frac(n/2^i) = 0 is when the bits of n at i-1 and below are all 0's. So a(n) is sum +1 for each 1-bit of n and -1 for each 0-bit of n but excluding any low 0's. - Kevin Ryde, Aug 31 2020

Examples

			For n = 10, a(10) = 0 + 1 + (-1) + 1 = 1.
		

Crossrefs

Programs

  • JavaScript
    var k = 1;
    var r = 0;
    for (var i = 0; i < 100; i += 1) {
        while ((i+1) >= Math.pow(2, k - 1)) {
            if (Math.round((i+1) / Math.pow(2, k)) < ((i+1) / Math.pow(2, k))) {
                r -= 1;
            } else if (Math.round((i+1) / Math.pow(2, k)) > ((i+1) / Math.pow(2, k))) {
                r += 1;
            } else {
                r += 0;
            }
            k += 1;
        }
        document.write(r, ", ");
        k = 1;
        r = 0;
    }
    
  • Mathematica
    Array[2 DigitCount[#, 2, 1] + IntegerExponent[#, 2] - Floor[Log2[#]] - 1 &, 80] (* Michael De Vlieger, Sep 01 2020 *)
  • PARI
    a(n) = sum(k = 1, 1+logint(n, 2), my(x=(n % 2^k)/2^k); sign(round(x) - x)); \\ Michel Marcus, Aug 23 2020
    
  • PARI
    a(n) = 2*hammingweight(n) + valuation(n,2) - logint(n,2) - 1; \\ Kevin Ryde, Aug 29 2020

Formula

a(n) = A145037(A000265(n)) = A145037(n) + A007814(n). - Kevin Ryde, Aug 31 2020

A350700 a(n) is the number of 1's minus the number of 0's in A004685(n).

Original entry on oeis.org

-1, 1, 1, 0, 2, 1, -2, 2, 1, -2, 4, 1, -4, 2, 3, -2, 6, 3, -4, -3, 3, -2, 1, 7, -4, -5, 1, 4, 3, 5, -4, 1, -4, 4, 1, -2, 0, 3, -6, -2, 5, 6, 0, 3, 6, -1, 11, -6, -9, 3, 2, -1, -1, -2, -5, 6, 4, -7, 8, 0, -9, -4, 10, 3, -4, 6, -7, 6, -17, -1, -2, -5, 1, 4, -3
Offset: 0

Views

Author

Karl-Heinz Hofmann, Jan 18 2022

Keywords

Examples

			A004685(0) = 0; this term has 0 ones and 1 zero. So a(0) = 0 - 1 = -1.
A004685(7) = 1101; this term has 3 ones and 1 zero. So a(7) = 3 - 1 = 2.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Subtract @@ DigitCount[Fibonacci[n], 2, {1, 0}]; Array[a, 75, 0] (* Amiram Eldar, Jan 22 2022 *)
  • Python
    from sympy import fibonacci
    print([(bin(fibonacci(n))[2:].count("1") - bin(fibonacci(n))[2:].count("0")) for n in range (0,100)])

Formula

a(n) = A145037(A000045(n)) for n >= 1.
a(n) = 0 if and only if n is in A214852. - Amiram Eldar, Jan 22 2022
Previous Showing 21-25 of 25 results.