A382307 Position of start of first run of alternating bit values in the base-2 representation of Pi, or -1 if no such run exists.
1, 2, 2, 19, 19, 19, 19, 19, 1195, 1697, 1890, 1890, 1890, 1890, 15081, 63795, 206825, 206825, 206825, 470577, 470577, 557265, 557265, 557265, 557265, 557265, 447666572, 447666572, 699793337, 699793337, 2049646803, 2250772991
Offset: 1
Examples
The first alternating bit run is "0", at position 1, so a(1) = 1. The second and third alternating bit runs are "01" and "010", starting at position 2, so a(2) and a(3) are both 2. a(4)-a(8) = 19 since the binary digits of Pi are "10101010" starting at position 19.
Programs
-
Python
def binary_not(binary_string): return ''.join('1' if bit == '0' else '0' for bit in binary_string) # !pip install gmpy2 # may be necessary import gmpy2 gmpy2.get_context().precision = 12000000 pi = gmpy2.const_pi() # Convert Pi to binary representation binary_pi = gmpy2.digits(pi, 2)[0] # zero-th element is the string of bits binary_pi = binary_pi[2:] # remove leading "11" left of decimal point outVec = [] strSearch0 = "" # this substring starts with "0" for lenRun in range(1,30): strSearch0 += "0" if lenRun%2==1 else "1" strSearch1 = binary_not(strSearch0) l0 = binary_pi.find(strSearch0)+1 # incr origin-0 result l1 = binary_pi.find(strSearch1)+1 outVec.append(min(l0,l1)) print(outVec)
Extensions
a(26)-a(32) from Pontus von Brömssen, Apr 06 2025
Comments