[Tutor] Fwd: Need help with Factorial algorithm using Python

Chris Fuller cfuller084 at thinkingplanet.net
Thu Sep 4 18:03:39 CEST 2008


The point of a lot of these challenges is to be smart with your math as well 
as your code.  A brute force approach isn't going to work very well, 
especially in this case.  An integer with 7^20 trailing zeros isn't even 
going to fit in your RAM.

An observation: every trailing zero implies a factor of ten, which in primes 
is two and five.  So the final number will have at least 7^20 twos and fives 
in its prime factorization.

Exploiting this fact in a clever way is probably one way to solve this 
problem.

Cheers


More information about the Tutor mailing list