Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #13426

Re: Reverse factorial

From "Ed" <invalid@nospam.com>
Newsgroups comp.lang.forth
Subject Re: Reverse factorial
Date 2012-07-02 05:40 +1000
Organization Aioe.org NNTP Server
Message-ID <jsq93l$983$1@speranza.aioe.org> (permalink)
References <jspim5$hcn$1@speranza.aioe.org> <92841902968435@frunobulax.edu>

Show all headers | View raw


Marcel Hendrix wrote:
> ...
> 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).

14!  produces an integer with 11 digits - more than we need
13!  produces an integer with 10 digits - better
12!  produces an integer with  9 digits - too low

> 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.

Given the previous paragraph, I wouldn't be too sure.

> The fix to my program is:
>
> : FIND-n! ( F: #digits -- n )
> ...
> #digits F>S  3 2 */  1 LOCALS| low high |
> ...
> high ;

Introducing a bias to overcome the error in the approximation
algorithm at small values.  Commonly known as fudging the
result.

> The result for 10^0 is wrong for both programs (0! = 1).

10^0 digits = 1 digit which satisfies 1!

0! = 1 is a convention supported by mathematical logic
(the same logic that gave you infinity along with some
infinities being greater than others :)

0! = 1 would not be directly computable and a program
would need to support it as a special case.


Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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