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

A373745 Maximum length of a run of alternating bits in the base-2 representation of prime(n).

Original entry on oeis.org

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

Views

Author

James S. DeArmon, Jun 16 2024

Keywords

Examples

			149 = prime(35) = 10010101_2 has two alternating bit runs of lengths 2 and 6: 10_010101, and thus a(35) = 6.
		

Crossrefs

Programs

  • Maple
    b:= n-> `if`(n<2, [n$2], (f-> (t-> [t, max(t, f[2])])(
            `if`(n mod 4 in {0, 3}, 1, f[1]+1)))(b(iquo(n, 2)))):
    a:= n-> b(ithprime(n))[2]:
    seq(a(n), n=1..94);  # Alois P. Heinz, Jul 08 2024
  • Python
    from sympy import prime
    def A373745(n):
        s = bin(prime(n))[2:]
        return next(i for i in range(len(s),0,-1) if ('01'*(i+1>>1))[:i] in s or ('10'*(i+1>>1))[:i] in s) # Chai Wah Wu, Jul 10 2024

Formula

a(n) = A374176(A000040(n)) + 1. - Alois P. Heinz, Jul 10 2024

A374402 Least number that is the lesser of two consecutive primes p and q whose binary expansions have the same length and agree at exactly n digit positions, or -1 if no such prime pair exists.

Original entry on oeis.org

2, 5, 23, 17, 41, 67, 137, 269, 521, 1049, 2081, 4111, 8233, 16417, 32771, 65537, 131113, 262147, 524309, 1048609, 2097257, 4194389, 8388617, 16777289, 33554501, 67109123, 134217929, 268435459, 536871017, 1073741827, 2147484041, 4294967497, 8589934627, 17179869731
Offset: 1

Views

Author

Jean-Marc Rebert, Jul 07 2024

Keywords

Examples

			a(1) = 2 because 2 = 10_2 and 3 = 11_2 are two consecutive primes that, when written in base 2, both have 2 digits and agree at exactly 1 digit position (each has a 1 in its first digit position), and no earlier pair of consecutive primes has this property.
a(3) = 23 = 10111_2; the next prime is
       29 = 11101_2  (same number of binary digits),
            ^ ^ ^    and the digits agree at 3 digit positions,
  and no earlier pair of consecutive primes has this property.
		

Crossrefs

Programs

  • PARI
    card(p)=my(u=binary(p),v=binary(nextprime(p+1))); if(#u!=#v,return(0)); sum(i=1,#u,u[i]==v[i])
    a(n)=forprime(p=2^n,oo,if(card(p)==n,return(p)))
Showing 1-2 of 2 results.