Calculating factorial

Alex Martelli aleaxit at yahoo.com
Wed Dec 6 06:45:57 EST 2000


"Tim Hochberg" <tim.hochberg at ieee.org> wrote in message
news:vr8X5.51298$15.10971944 at news1.rdc1.az.home.com...
    [snip]
> > Since range(N) takes up memory space growing as O(N), for a
> > large enough N this memory consumption becomes irrelevant
> > compared to the memory which N! itself takes up.
>
> This is not true. If range supported long integers, for _really_ large N,
> range(N) would take up O(sum(log i))=O(log(N!)) memory space. So it would

Good (theoretical) point!  Oh well, at least I have good company in
this particular blind-spot (who was the eminent computer scientist
who claimed O(N) behavior for keysort -- forgetting that for large
enough N, the logN number-of-digits factor comes in, making the
whole O(N logN) again...?-).


Alex






More information about the Python-list mailing list