On Wednesday, 21 January 2015 15:06:33 UTC-4, Chris Angelico wrote: > On Thu, Jan 22, 2015 at 5:20 AM, Irmen de Jong wrote: > > On 21-1-2015 18:59, Steve Hayes wrote: > > > >> 3. When I started to look at it, I found that strings could be any length > >> and > >> were not limited to swomething arbitrary, like 256 characters. > > > > Even more fun is that Python's primitive integer type (longs for older > > Python versions) > > has no arbitrary limitation either. > > > > That amazed me at the time I discovered python :) > > I hadn't worked with length-limited strings in basically forever > (technically BASIC has a length limit, but I never ran into it; and I > never did much with Pascal), but you're right, arbitrary-precision > integers would have impressed me a lot more if I hadn't first known > REXX. So... is there a way to show that off efficiently?
How about: >>> def fac(n): ... ans = 1 ... while n > 1: ... ans *= n ... n -= 1 ... return ans ... >>> a = fac(100) >>> a 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000 >>> b = fac(102) >>> b 961446671503512660926865558697259548455355905059659464369444714048531715130254590603314961882364451384985595980362059157503710042865532928000000000000000000000000 >>> b//a 10302 >>> b//a == 102 * 101 True André Normally, any > calculation that goes beyond 2**32 has already gone way beyond most > humans' ability to hold the numbers in their heads. > > ChrisA -- https://mail.python.org/mailman/listinfo/python-list