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.

A239316 Index of the first occurrence of a string of exactly n consecutive odd digits in the decimal expansion of Pi.

This page as a plain text file.
%I A239316 #34 May 22 2025 10:21:37
%S A239316 18,1,4,13,282,342,783,43,4424,412,940,8337,44968,61667,33821,106904,
%T A239316 336404,421527,31488,1850725,5854551,8996526,11709660,2493200,
%U A239316 105887707,86401248,701257139,546257302,92438127
%N A239316 Index of the first occurrence of a string of exactly n consecutive odd digits in the decimal expansion of Pi.
%e A239316 Digit:       1 2 3 4 5 6 7 8 9 10 11 12 ...18 ...
%e A239316 Pi:          3 1 4 1 5 9 2 6 5  3  5  8 ....3 ...
%e A239316 Odd string:  [2]...[ 3 ].....[  3  ].......[1]...
%e A239316              .       .                      .
%e A239316              .       .                      .
%e A239316             a(2)    a(3)                   a(1)
%e A239316             = 1     = 4                    = 18
%t A239316 a239316[n_, checkDigits_: 100000] :=
%t A239316 Block[{foundPos,
%t A239316    piDigitBooleans = {#1[[1]],
%t A239316        Length[#]} & /@ (OddQ /@
%t A239316         RealDigits[N[Pi, checkDigits]][[1, 1 ;; All]] // Split)},
%t A239316   foundPos = FirstPosition[piDigitBooleans, {True, n}][[1]];
%t A239316   If[! NumericQ[foundPos],
%t A239316    Return["Not found within " <> ToString[checkDigits] <> " digits"]];
%t A239316    Total[piDigitBooleans[[1 ;; foundPos]][[All, 2]]] - n + 1]
%t A239316 a239316[#] & /@ Range[1, 15] (* _Julien Kluge_, Jan 31 2016 *)
%o A239316 (Python)
%o A239316 with open("pib.txt") as f:
%o A239316     digits = f.read(1000000000)
%o A239316     for a in range(1,30):
%o A239316         found = False
%o A239316         place = 0
%o A239316         now = 0
%o A239316         while place < 999999999:
%o A239316             b = int(digits[place])
%o A239316             c = int(digits[place+1])
%o A239316             if b % 2 == 1:#digit is odd
%o A239316                 now += 1
%o A239316             else:
%o A239316                 now = 0
%o A239316             if now == a and c%2 == 0:
%o A239316                 print(a,place-a+2)
%o A239316                 found = True
%o A239316                 break
%o A239316             place += 1
%o A239316         if not found:
%o A239316             print("Not found in first billion digits.")
%o A239316 # pib.txt is the first billion digits of pi, readily available online
%o A239316 # _David Consiglio, Jr._, Sep 22 2014
%Y A239316 Cf. A000796, A057680, A239317.
%K A239316 nonn,base
%O A239316 1,1
%A A239316 _Kival Ngaokrajang_, Mar 15 2014
%E A239316 More terms from _David Consiglio, Jr._, Sep 22 2014