Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20427
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Reverse factorial |
| Date | 2013-03-08 09:14 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <khca5v$drk$1@dont-email.me> (permalink) |
| References | <jsj1ni$v5g$1@speranza.aioe.org> |
Ed wrote:
> 15 set-precision
>
> 1e9 fconstant #digits
>
> : N! ( -- )
> 0.0e ( N)
> 0.0e ( A)
> begin
> fswap 1.0e f+ fswap
> fover flog f+
> fdup [ #digits 1.0e f- ] fliteral f< 0=
> until
> ( N A) fdrop f.
> ;
>
> : run ( -- )
> cr cr ." Smallest number with a factorial of at least "
> #digits fs. ." digits is ... " cr n!
> ;
>
> run
>
> --
>
> 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
Factor:
USING: locals math.functions ;
CONSTANT: #digits 1e9
:: N! ( -- )
0.0 :> n!
0.0 :> a!
[ n 1.0 + n!
a n log10 + a!
a #digits 1.0 - <
]
loop
n .
;
N!
130202809.0
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll 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
Re: Reverse factorial "WJ" <w_a_x_man@yahoo.com> - 2013-03-08 09:14 +0000
csiph-web