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-26 of 26 results.

A223909 Numbers for which the maximal run of 1's in their binary representation contains odd number of 1's.

Original entry on oeis.org

1, 2, 4, 5, 7, 8, 9, 10, 14, 16, 17, 18, 20, 21, 23, 28, 29, 31, 32, 33, 34, 36, 37, 39, 40, 41, 42, 46, 55, 56, 57, 58, 59, 62, 64, 65, 66, 68, 69, 71, 72, 73, 74, 78, 80, 81, 82, 84, 85, 87, 92, 93, 95, 103, 110, 112, 113, 114, 115, 116, 117, 118, 119, 124
Offset: 1

Views

Author

Vladimir Shevelev, Mar 29 2013

Keywords

Comments

We call these numbers "maxodious".
If a(n) is in the sequence, then 2^k*a(n) is in the sequence. If a(n)==0 (mod 4) is in the sequence, then a(n)+1 is in the sequence. If a(n)==0 (mod 8) is in the sequence, then a(n)+1, a(n)+2 are in the sequence.

Crossrefs

Programs

Formula

Numbers n such that A038374(n) is odd. - Charles R Greathouse IV, Jan 12 2014

A300655 a(n) is the length of the longest contiguous block of ones in the binary expansion of 1/n.

Original entry on oeis.org

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

Views

Author

Rémy Sigrist, Mar 10 2018

Keywords

Comments

This sequence has similarities with A038374: here we consider the binary expansion of 1/n, there the binary expansion of n.

Examples

			The first terms, alongside the binary representation of 1/n, are:
  n   a(n)  bin(1/n) with repeating digits in parentheses
  --  ----  ---------------------------------------------
   1     1  1.(0)
   2     1  0.1(0)
   3     1  0.(01)
   4     1  0.01(0)
   5     2  0.(0011)
   6     1  0.0(01)
   7     1  0.(001)
   8     1  0.001(0)
   9     3  0.(000111)
  10     2  0.0(0011)
  11     3  0.(0001011101)
  12     1  0.00(01)
  13     3  0.(000100111011)
  14     1  0.0(001)
  15     1  0.(0001)
  16     1  0.0001(0)
  17     4  0.(00001111)
  18     3  0.0(000111)
  19     4  0.(000011010111100101)
  20     2  0.00(0011)
		

Crossrefs

Programs

  • PARI
    a(n) = my (w=1, s=Set(), f=1/max(n,2)); while (!setsearch(s,f), while (floor(f*2^(w+1))==2^(w+1)-1, w++); s=setunion(s,Set(f)); f=frac(f*2)); return (w)

Formula

a(2*n) = a(n).
a(2^k + 1) = k for any k > 0.
a(n) = 1 iff n belongs to A300630.

A092607 Length of longest contiguous block of ones in binary representation of n!.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Apr 11 2004

Keywords

Examples

			n = 10: 10! = 3628800 = '1101110101111100000000' = '.........11111........': a(10) = 5.
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Max[Length /@ Split[IntegerDigits[n!, 2]][[1 ;; -1 ;; 2]]]; Array[a, 100, 0] (* Amiram Eldar, Jul 29 2025 *)

Formula

a(n) = A038374(A000142(n)).

A245536 Write n>=1 as either n=2^k-2^r with 0 <= r <= k-1, in which case a(2^k-2^r)=k-r-1, or as n=2^k-2^r+j with 2 <= r <= k-1, 1 <= j < 2^r-1, in which case a(2^k-2^r+j)=(k-r-1)*a(j).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Jul 25 2014

Keywords

Comments

Defined by the recurrence given in A245196, taking G(n)=n (n>=0) and m=1.
Changing G from [0,1,2,3,4,...] to [1,2,3,4,5,6,...] produces A038374.

Crossrefs

Programs

  • Maple
    G:=[seq(n,n=0..30)];
    m:=1;
    f:=proc(n) option remember; global m,G; local k,r,j,np;
       k:=1+floor(log[2](n)); np:=2^k-n;
       if np=1 then r:=0; j:=0; else r:=1+floor(log[2](np-1)); j:=2^r-np; fi;
       if j=0 then G[k-r-1+1]; else m*G[k-r-1+1]*f(j); fi;
    end;
    [seq(f(n),n=1..120)];

A307503 Least prime containing at least n consecutive 1's in its binary representation.

Original entry on oeis.org

2, 2, 3, 7, 31, 31, 127, 127, 1021, 3583, 4093, 6143, 8191, 8191, 81919, 131071, 131071, 131071, 524287, 524287, 4194301, 14680063, 16777213, 67108859, 536870909, 536870909, 536870909, 536870909, 2147483647, 2147483647, 2147483647, 2147483647, 21474836479
Offset: 0

Views

Author

John Mason, Apr 11 2019

Keywords

Comments

For n > 0, a(n) = A000040(m) for the lowest m such that A090000(m) >= n.
a(n) = A087522(n) for n = 0 through 7, and in all other cases when a(n) is a base 2 repunit (Mersenne) prime.

Examples

			a(0) = 2, the smallest prime containing >= 0 1's.
a(1) = 2, the smallest prime containing >= 1 consecutive 1's.
a(2) = 3, the smallest prime containing >= 2 consecutive 1's.
		

Crossrefs

Cf. A090593 (with exactly n consecutive ones).

Programs

  • PARI
    nbo(n)=if (n==0, return (0)); n>>=valuation(n, 2); if(n<2, return(n)); my(e=valuation(n+1, 2)); max(e, nbo(n>>e)); \\ A038374
    a(n) = my(p=2); while(nbo(p) < n, p=nextprime(p+1)); p; \\ Michel Marcus, Apr 14 2019

Formula

a(n) <= A201914(n). - Rémy Sigrist, Apr 11 2019
a(n) = min_{k>=n} A090593(k). - Chai Wah Wu, Apr 26 2019

Extensions

a(28)-a(32) from Chai Wah Wu, Apr 26 2019

A383270 Length of the longest sequence of contiguous 1s in the binary expansion of n after flipping at most one 0-bit to 1.

Original entry on oeis.org

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

Views

Author

Darío Clavijo, Apr 21 2025

Keywords

Comments

There is only one allowed bit flip from 0 to 1 for each term, unless n is of the form 2^k-1 in which case a(n) = k.
At most one bit flip from 0 to 1 is allowed. If the original binary representation already contains the longest run of 1s, no flip is required.

Examples

			a(3) = 2 because 3 = 11_2 and there is no need to flip any bit.
a(1775) = 8 because 1775 = 11011101111_2 and if we flip the 7th bit we get 1101111111_2 which has the longest sequence of contiguous 1s of length 8.
		

Crossrefs

Programs

  • PARI
    a(n) = if (n==0, return(1)); my(b=binary(n), vz = select(x->(x==0), b, 1), m=0); if (#vz <= 1, return (#b)); vz = concat(0, concat(Vec(vz), #b+1)); for (i=1, #vz-2, m = max(m, vz[i+2]-vz[i]-1)); m; \\ Michel Marcus, May 02 2025
  • Python
    def a(n):
        if n == 0: return 1
        if n.bit_length() == n.bit_count(): return n.bit_length()
        c = p = m = 0
        while n:
            if n & 1: c += 1
            else:
                p = c * ((n & 2) > 0)
                c = 0
            if (pc := p + c) > m: m = pc
            n >>= 1
        return m + 1
    print([a(n) for n in range(1,88)])
    

Formula

a(n) <= 1 + floor(log_2(n)).
a(2^k-1) = k.
a(2^k) = 2 for k > 0.
a(2^k+1) = 2.
A038374(n) <= a(n) <= A000120(n)+1. - Michael S. Branicky, Apr 21 2025
Previous Showing 21-26 of 26 results.