Group: comp.lang.tcl


Subject: Advice required BigNums in calculation
From: Glenn Jackman
Date: 12/4/2007 9:15:41 PM
At 2007-12-04 03:31PM, "suchenwi" wrote: > I'm not doing any bioinformatics, but can't resist a challenge > either... :^) > $ tclsh85 > % proc ! x {set res 1; while {$x>1} {set res [expr {$res*$x}]; incr x > -1}; set r > es} > % ! 32 > 263130836933693530167218012160000000 > % ! 10000 > 28462596809170545189064132121198688901480514017027992307941799942744113400037644 [... 444 lines deleted ...] > 000000000000000000000000000000000000000000000000000000000000 > % time {! 10000} > 2146958 microseconds per iteration > > That's on my semi-ancient 700 MHz Win XP box. and curiosity strikes me ... tkcon somehow doesn't like proc name !, so I used "fac": % time {set ans [fac 10000]} 941777 microseconds per iteration % array set digits {0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0} % for {set i [string length $ans]} {$i >= 0} {incr i -1} { incr digits([string index $ans $i]) } % parray digits digits() = 1 digits(0) = 5803 digits(1) = 3241 digits(2) = 3416 digits(3) = 3258 digits(4) = 3341 digits(5) = 3324 digits(6) = 3324 digits(7) = 3335 digits(8) = 3336 digits(9) = 3282 -- Glenn Jackman "You can only be young once. But you can always be immature." -- Dave Barry