Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13397
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Subject | Re: Reverse factorial |
| Newsgroups | comp.lang.forth |
| Message-ID | <60980105978435@frunobulax.edu> (permalink) |
| Date | 2012-06-30 02:05 +0200 |
| References | <jsj1ni$v5g$1@speranza.aioe.org> |
| Organization | Wanadoo |
"Ed" <invalid@nospam.com> writes Re: Reverse factorial > Here's a reverse factorial routine to wile away your free time. > As the routine is highly f/p intensive it can double as a benchmark > for testing relative performance between systems and implementation > details such as separate/common/hardware f/p stacks. Not this one. [..] > DX-Forth 3.98 2012-06-26 > Forth-94 > 80387 15-digit floating point (common stack) > include n! > Smallest number with a factorial of at least 1.E9 digits is ... > 130202809. ok [..] FORTH> runs Smallest number with a factorial of at least 10^6 digits is 205023 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^7 digits is 1723508 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^8 digits is 14842907 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^9 digits is 130202809 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^10 digits is 1158787578 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^11 digits is 10433891464 \ 0.001 seconds elapsed. Smallest number with a factorial of at least 10^12 digits is 94851898541 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^13 digits is 869200494600 \ 0.001 seconds elapsed. Smallest number with a factorial of at least 10^14 digits is 8019346203786 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^15 digits is 74419210652836 \ 0.001 seconds elapsed. Smallest number with a factorial of at least 10^16 digits is 694100859679692 \ 0.000 seconds elapsed. Smallest number with a factorial of at least 10^17 digits is 6502464891216880 \ 0.001 seconds elapsed. Smallest number with a factorial of at least 10^18 digits is 61154108320430276 \ 0.000 seconds elapsed. ok -marcel -- ---------------------------------------------------------- : LOG(N!) ( n -- ) ( F: -- log[n!] ) S>F FLOCAL n PI*2 n F* FLOG F2/ n 1e FEXP F/ FLOG n F* F+ 12e n F* 1/F F1+ 288e n FSQR F* 1/F F+ 139e 512840e n F* n F* n F* F/ F- 571e 2488320e n FSQR FSQR F* F/ F- FLOG F+ ; : FIND-n! ( F: #digits -- n ) FLOCAL #digits #digits F>S 1 LOCALS| low high | BEGIN low high + 2/ LOG(N!) #digits F>= IF low high + 2/ TO high ELSE low high + 2/ TO low ENDIF low 1+ high >= UNTIL high ; : run ( #digits -- ) CR ." Smallest number with a factorial of at least 10^" DUP . ." digits is " timer-reset 10e S>F F** FIND-n! . ." \ " .elapsed ; : runs ( -- ) #19 6 DO I run LOOP ;
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Reverse factorial "Ed" <invalid@nospam.com> - 2012-06-29 11:51 +1000
Re: Reverse factorial mhx@iae.nl (Marcel Hendrix) - 2012-06-30 02:05 +0200
Re: Reverse factorial "Ed" <invalid@nospam.com> - 2012-06-30 12:26 +1000
Re: Reverse factorial "Ed" <invalid@nospam.com> - 2012-07-01 23:17 +1000
Re: Reverse factorial mhx@iae.nl (Marcel Hendrix) - 2012-07-01 16:51 +0200
Re: Reverse factorial "Ed" <invalid@nospam.com> - 2012-07-02 05:40 +1000
Re: Reverse factorial Paul Rubin <no.email@nospam.invalid> - 2012-07-02 22:08 -0700
Re: Reverse factorial "Ed" <invalid@nospam.com> - 2012-07-03 17:02 +1000
Re: Reverse factorial mhx@iae.nl (Marcel Hendrix) - 2012-07-03 21:14 +0200
Re: Reverse factorial Paul Rubin <no.email@nospam.invalid> - 2012-07-03 12:44 -0700
Re: Reverse factorial mhx@iae.nl (Marcel Hendrix) - 2012-07-03 22:37 +0200
Re: Reverse factorial "Ed" <invalid@nospam.com> - 2012-07-05 23:14 +1000
csiph-web