A239316 Index of the first occurrence of a string of exactly n consecutive odd digits in the decimal expansion of Pi.
18, 1, 4, 13, 282, 342, 783, 43, 4424, 412, 940, 8337, 44968, 61667, 33821, 106904, 336404, 421527, 31488, 1850725, 5854551, 8996526, 11709660, 2493200, 105887707, 86401248, 701257139, 546257302, 92438127
Offset: 1
Examples
Digit: 1 2 3 4 5 6 7 8 9 10 11 12 ...18 ... Pi: 3 1 4 1 5 9 2 6 5 3 5 8 ....3 ... Odd string: [2]...[ 3 ].....[ 3 ].......[1]... . . . . . . a(2) a(3) a(1) = 1 = 4 = 18
Programs
-
Mathematica
a239316[n_, checkDigits_: 100000] := Block[{foundPos, piDigitBooleans = {#1[[1]], Length[#]} & /@ (OddQ /@ RealDigits[N[Pi, checkDigits]][[1, 1 ;; All]] // Split)}, foundPos = FirstPosition[piDigitBooleans, {True, n}][[1]]; If[! NumericQ[foundPos], Return["Not found within " <> ToString[checkDigits] <> " digits"]]; Total[piDigitBooleans[[1 ;; foundPos]][[All, 2]]] - n + 1] a239316[#] & /@ Range[1, 15] (* Julien Kluge, Jan 31 2016 *)
-
Python
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 == 1:#digit is odd now += 1 else: now = 0 if now == a and c%2 == 0: print(a,place-a+2) found = True break place += 1 if not found: print("Not found in first billion digits.") # pib.txt is the first billion digits of pi, readily available online # David Consiglio, Jr., Sep 22 2014
Extensions
More terms from David Consiglio, Jr., Sep 22 2014