3141, 0582, ____, 2796, 6549, ____...
And just as night follows the day - here are 4-digit patterns
seen in the digits of pi for the first time, the second time, etc,
as one scans the digits.
1 3141
2 0582
3 9999
4 2796
5 6549
6 2019
The program is below.
I am unhappy because this challenge enticed me to break my New Year's resolution of sticking to the deeper problems. :-)
program pi
implicit none
integer cntmax,pattern,i,j,p(10000),cnt(0:9999)
data cnt/10000*0/
open(2,file='pi.txt',status='old')
cntmax=0
read(2,3)(p(i),i=1,10000)
3 format(10000i1)
do j=1,9997
pattern=1000*p(j)+100*p(j+1)+10*p(j+2)+p(j+3)
cnt(pattern)=cnt(pattern)+1
if(cnt(pattern).gt.cntmax)then
print*,cnt(pattern),pattern
cntmax=cnt(pattern)
if(cntmax.eq.6)call exit
endif
enddo
end