Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13418
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Subject | Re: Reverse factorial |
| Newsgroups | comp.lang.forth |
| Message-ID | <92841902968435@frunobulax.edu> (permalink) |
| Date | 2012-07-01 16:51 +0200 |
| References | <jspim5$hcn$1@speranza.aioe.org> |
| Organization | Wanadoo |
"Ed" <invalid@nospam.com> writes Re: Reverse factorial > Marcel Hendrix wrote: [..] > I get these results using your algorithm > Smallest number with a factorial of at least 10^0 digits: 1. > Smallest number with a factorial of at least 10^1 digits: 10. [..] > Smallest number with a factorial of at least 10^6 digits: 205023. > While the original (slow) routine gives > Smallest number with a factorial of at least 1.E0 digits: 1. > Smallest number with a factorial of at least 1.E1 digits: 13. [..] > Smallest number with a factorial of at least 1.E6 digits: 205022. [..] According to Wolfram Alpha, log10(13!) = 9.79428031638948 log10(14!) = 10.940408352067719 Therefore the result for 10^1 digits should be 14, not 13. My program is wrong, but not because log(n!) is faulty (see below). According to Wolfram Alpha, log10(205022!) = 999999.08681421082059069559626773741428638233100481270 log10(205023!) = 1.00000439861679486551512255600216645545545382220e6 Therefore 205023 as the "Smallest number with a factorial of at least 10^6 digits" is correct. The fix to my program is: : FIND-n! ( F: #digits -- n ) ... #digits F>S 3 2 */ 1 LOCALS| low high | ... high ; The result for 10^0 is wrong for both programs (0! = 1). As should be obvious, I didn't test my code for 10^0 and 10^1 digits. -marcel
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