Iteration for Factorials

Marco Mariani marco at sferacarta.com
Tue Oct 23 17:24:26 CEST 2007


Roberto Bonvallet wrote:

> 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))


You solution reminds me the web-based WTF calculator.

http://worsethanfailure.com/Articles/OMGWTF-Finalist-05-WTF-Web-Calc.aspx



More information about the Python-list mailing list