From:

Date:

August 8, 2002 11:04Subject:

Factorial and large numbers.Message ID:

B9787F12.EC56%torhildr@mac.comCould someone annotate some of the various working solutions, emphasizing how they work around the problem with large numbers? I was able to make solutions that worked for n! where n < 25. But, at 25! the numbers got to large. I tried regex'ing the last zeroes, without success. I was still loosing digits. -p $v=$_;for($_=1;$v>0;){$_*=$v--}s/0//g;$_=chop."\n" My shortest solution, but still in the sandtrap. I'm basically just counting down 'n' with $_*=$v--; n=9 => 9*8*7*6*5*4*3*2*1 But, at 25!, the numbers are getting to big, so it's not accurate enough. I tried with: -p $v=$_;for($_=1;$v>0;){$_*=$v--;s/0*$//}s/0//g;$_=chop."\n" ^^^^^^ But, that didn't help much. :( I also hate $_=chop."\n", but couldn't figure out anything else. What does $`%9e9 do? Couldn't even get a working solution on my virgin hole :) TorThread Next

**Factorial and large numbers.**by Tor Hildrum- Re: Factorial and large numbers. by Markus Laire
- Re: Factorial and large numbers. by perl-golf
- Re: Factorial and large numbers. by Markus Laire
- Re: Factorial and large numbers. by Stephen Turner
- Re: Factorial and large numbers. by Eugene van der Pijll
- Re: Factorial and large numbers. by Tor Hildrum

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About