PPS The code was successfully tested e.g. here: http://www.spoj.pl/ranks/FACT1/ (see my 2nd and 4th places). They confused versions: the 2nd is in Python 2.5, not 2.6.2. PPPS Funnilly... almost only Python on the 1st page =)