Iteration for Factorials
Roberto Bonvallet
rbonvall at gmail.com
Tue Oct 23 10:26:59 EDT 2007
On Oct 22, 11:45 am, Ant <ant... at gmail.com> wrote:
> Er, no. And neither is mine. You may want to google for the definition
> of factorial!
Don't google for the definition... google for the answer!
import urllib
import re
urllib.URLopener.version = "Mozilla/4.0"
def fact(x):
r = re.compile(r"%d ! = (\d+)" % x)
for line in urllib.urlopen("http://www.google.cl/search?q=%d%%21"
% x):
m = r.search(line)
if m:
return int(m.group(1))
--
Roberto Bonvallet
More information about the Python-list
mailing list