arbitrary long integer aritmetics

Miki Tebeka tebeka at cs.bgu.ac.il
Wed Jul 2 14:07:43 CEST 2003


Hello Leo,

> is there a python module around allow using arbitrary long integers?
> 
> i.e. the result of an integer operation is as long as necessary, so that a*b
> never produces an overflow error. (but rather an out of memory error ;-) )
It's built in:
>>> from operator import mul
>>> def fact(x):
	return reduce(mul, range(2, x + 1), 1)
>>> fact(100L)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L

HTH.
Miki




More information about the Python-list mailing list