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.

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

This page as a plain text file.
%I A373745 #53 Jul 10 2024 16:05:21
%S A373745 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,
%T A373745 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,
%U A373745 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
%N A373745 Maximum length of a run of alternating bits in the base-2 representation of prime(n).
%F A373745 a(n) = A374176(A000040(n)) + 1. - _Alois P. Heinz_, Jul 10 2024
%e A373745 149 = prime(35) = 10010101_2 has two alternating bit runs of lengths 2 and 6: 10_010101, and thus a(35) = 6.
%p A373745 b:= n-> `if`(n<2, [n$2], (f-> (t-> [t, max(t, f[2])])(
%p A373745         `if`(n mod 4 in {0, 3}, 1, f[1]+1)))(b(iquo(n, 2)))):
%p A373745 a:= n-> b(ithprime(n))[2]:
%p A373745 seq(a(n), n=1..94);  # _Alois P. Heinz_, Jul 08 2024
%o A373745 (Python)
%o A373745 from sympy import prime
%o A373745 def A373745(n):
%o A373745     s = bin(prime(n))[2:]
%o A373745     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
%Y A373745 Cf. A000040, A374176.
%K A373745 nonn,base,easy
%O A373745 1,1
%A A373745 _James S. DeArmon_, Jun 16 2024