Search Pi

November 29 2005 Alec Mihailovs 4095
Maple

0

Will mentioned in his blog a problem of finding the first occurence in π the given sequence of digits - a birthday, for example. It can be done in Maple through the search engine at http://www.angio.net/pi/piquery as follows,
SearchPi:=proc(x) 
local s,a,b;
uses StringTools, Sockets;
s:=Open("www.angio.net",80);
Write(s,cat("GET /pi/bigpi.cgi?UsrQuery=",x," HTTP/1.0\n\n"));
a := "";
		b := Read(s):
		while b <> false do
			a := cat(a,b);
			b := Read(s):
		end do;
Close(s);
s:=parse(Select(IsDigit,a[Search("position",a)+9..Search("counting",a)-2]));
if length(s)<16 then s else FAIL fi
end:
For example,
SearchPi(122282);
                               1673020
SearchPi(12221982);
                               43406818
SearchPi("000");
                                 601
Please Wait...