A239317 Index of the first occurrence of a string of exactly n even numbers in the decimal expansion of Pi.
3, 7, 53, 117, 33, 19, 965, 372, 1834, 70, 5876, 8878, 9288, 1279, 173580, 248625, 652113, 678288, 2199379, 1656691, 3455554, 30021792, 18707922, 26568757, 189709607, 36454145, 255896738, 388817627
Offset: 1
Examples
Digit: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... Pi: 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 ... Even string: ...[1]......[2].........[1]............ . . . . a(1) a(2) = 3 = 7
Programs
-
Mathematica
Module[{nn=389*10^6,dep},dep=If[EvenQ[#],1,0]&/@RealDigits[Pi,10,nn][[1]];Table[SequencePosition[dep,Join[{0},PadLeft[{0},n,1]],1][[1]],{n,2,29}][[All,1]]]+1 (* Harvey P. Dale, Jan 27 2022 *)
-
Python
# Requires a text file "pib.txt" that contains the first billion digits of pi # without a decimal point or line breaks with open("pib.txt") as f: digits = f.read(1000000000) for a in range(1,30): found = False place = 0 now = 0 while place < 999999999: b = int(digits[place]) c = int(digits[place+1]) if b % 2 == 0:#digit is odd now += 1 else: now = 0 if now == a and c%2 == 1: print(a,place-a+2) found = True break place += 1 if not found: print("Not found in first billion digits.") # David Consiglio, Jr., Sep 22 2014 # indentation corrected by David Radcliffe, May 09 2025
Extensions
More terms from David Consiglio, Jr., Sep 22 2014
Corrected and definition clarified by Harvey P. Dale, Jan 27 2022
Comments