Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A373745 Maximum length of a run of alternating bits in the base-2 representation of prime(n). 1
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 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,1
LINKS
FORMULA
a(n) = A374176(A000040(n)) + 1. - Alois P. Heinz, Jul 10 2024
EXAMPLE
149 = prime(35) = 10010101_2 has two alternating bit runs of lengths 2 and 6: 10_010101, and thus a(35) = 6.
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
PROG
(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
CROSSREFS
Sequence in context: A244797 A308659 A145652 * A368290 A111248 A100714
KEYWORD
nonn,base,easy
AUTHOR
James S. DeArmon, Jun 16 2024
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 11 17:54 EDT 2024. Contains 375839 sequences. (Running on oeis4.)