[Tutor] how to handle big numbers

Steven D'Aprano steve at pearwood.info
Sat Dec 10 00:18:38 CET 2011


surya k wrote:
> Finding factorial of 8 or 9 isn't big. If I would like to find factorial of 32327, how can I ?? 		 	   		  



py> import math
py> n = math.factorial(32327)  # takes about 2 seconds on my computer
py> s = str(n)  # takes about 30 seconds
py> len(s)
131744
py> print s[:10] +  "..." + s[-10:]
8648628691...0000000000



-- 
Steven



More information about the Tutor mailing list