develooper Front page | | Postings from August 2002

Re: Factorial and large numbers.

Thread Previous | Thread Next
August 8, 2002 13:18
Re: Factorial and large numbers.
Message ID:
In article <3D52E88C.16537.23333D2@localhost>,
	"Markus Laire" <> writes:
> You need to regex last zeroes AND remove extra numbers in the 
> beginning keeping only last 6 (or so) numbers.

Interesting enough you need 6 when counting up and 5 when counting down
> I can't resist mentioning my other solution which doesn't compute n! 
> at all, but just uses kind-of 3D lookup-table to find the result. 
> It's fast but unfortunately code is far too long :(
> $z=pop;sub g{vec"\x10\xd7\xa9\x98b\xef",pop,2}
> print$z<2||(1+g$z%25)*(1,3,2,4)[g 24-$z/25%25]*6*(1+g$z/625)%10,$/
> Explanation would be somewhat longer, but if anyone wants I can write 
> it.
> Has anyone else tried lookup instead of computing n!. I'd like to 
> know shortest possible solution for this sub-problem also.
For a general direct method, see

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About