Distribution of 0 digits in factorial series: Difference between revisions

Content added Content deleted
m (Undo revision 327367 by Thundergnat (talk)Copy paste error)
Tag: Undo
m (syntax highlighting fixup (for real this time))
Line 41: Line 41:
permanently falls below 0.16. This task took many hours in the Python example, though I wonder if there is a faster
permanently falls below 0.16. This task took many hours in the Python example, though I wonder if there is a faster
algorithm out there.
algorithm out there.

=={{header|11l}}==
=={{header|11l}}==
{{trans|Python}}
{{trans|Python}}


<lang 11l>F facpropzeros(n, verbose = 1B)
<syntaxhighlight lang="11l">F facpropzeros(n, verbose = 1B)
V proportions = [0.0] * n
V proportions = [0.0] * n
V (fac, psum) = (BigInt(1), 0.0)
V (fac, psum) = (BigInt(1), 0.0)
Line 60: Line 59:


L(n) [100, 1000, 10000]
L(n) [100, 1000, 10000]
facpropzeros(n)</lang>
facpropzeros(n)</syntaxhighlight>


{{out}}
{{out}}
Line 70: Line 69:


=== Base 1000 version ===
=== Base 1000 version ===
<lang 11l>F zinit()
<syntaxhighlight lang="11l">F zinit()
V zc = [0] * 999
V zc = [0] * 999
L(x) 1..9
L(x) 1..9
Line 124: Line 123:
print(‘The mean proportion dips permanently below 0.16 at ’first‘.’)
print(‘The mean proportion dips permanently below 0.16 at ’first‘.’)


meanfactorialdigits()</lang>
meanfactorialdigits()</syntaxhighlight>


{{out}}
{{out}}
Line 133: Line 132:
The mean proportion dips permanently below 0.16 at 47332.
The mean proportion dips permanently below 0.16 at 47332.
</pre>
</pre>

=={{header|C++}}==
=={{header|C++}}==
{{trans|Phix}}
{{trans|Phix}}
<lang cpp>#include <array>
<syntaxhighlight lang="cpp">#include <array>
#include <chrono>
#include <chrono>
#include <iomanip>
#include <iomanip>
Line 206: Line 204:
std::cout << "The mean proportion dips permanently below 0.16 at " << first
std::cout << "The mean proportion dips permanently below 0.16 at " << first
<< ". (" << elapsed(t0) << "ms)\n";
<< ". (" << elapsed(t0) << "ms)\n";
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 215: Line 213:
The mean proportion dips permanently below 0.16 at 47332. (4598ms)
The mean proportion dips permanently below 0.16 at 47332. (4598ms)
</pre>
</pre>

=={{header|Go}}==
=={{header|Go}}==
===Brute force===
===Brute force===
Line 221: Line 218:
{{libheader|Go-rcu}}
{{libheader|Go-rcu}}
Timings here are 2.8 seconds for the basic task and 182.5 seconds for the stretch goal.
Timings here are 2.8 seconds for the basic task and 182.5 seconds for the stretch goal.
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 261: Line 258:
fmt.Println(" (stays below 0.16 after this)")
fmt.Println(" (stays below 0.16 after this)")
fmt.Printf("%6s = %12.10f\n", "50,000", sum / 50000)
fmt.Printf("%6s = %12.10f\n", "50,000", sum / 50000)
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 276: Line 273:
{{trans|Phix}}
{{trans|Phix}}
Much quicker than before with 10,000 now being reached in 0.35 seconds and the stretch goal in about 5.5 seconds.
Much quicker than before with 10,000 now being reached in 0.35 seconds and the stretch goal in about 5.5 seconds.
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 363: Line 360:
fmt.Println(" (stays below 0.16 after this)")
fmt.Println(" (stays below 0.16 after this)")
fmt.Printf("%6s = %12.10f\n", "50,000", total/50000)
fmt.Printf("%6s = %12.10f\n", "50,000", total/50000)
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 369: Line 366:
Same as 'brute force' version.
Same as 'brute force' version.
</pre>
</pre>

=={{header|jq}}==
=={{header|jq}}==
'''Works with jq'''
'''Works with jq'''
Line 378: Line 374:


'''From BigInt.jq'''
'''From BigInt.jq'''
<syntaxhighlight lang="jq">
<lang jq>
# multiply two decimal strings, which may be signed (+ or -)
# multiply two decimal strings, which may be signed (+ or -)
def long_multiply(num1; num2):
def long_multiply(num1; num2):
Line 420: Line 416:
else mult($a1[1]; $a2[1]) | adjustsign( $a1[0] * $a2[0] )
else mult($a1[1]; $a2[1]) | adjustsign( $a1[0] * $a2[0] )
end;
end;
</syntaxhighlight>
</lang>
'''The task'''
'''The task'''
<syntaxhighlight lang="jq">
<lang jq>
def count(s): reduce s as $x (0; .+1);
def count(s): reduce s as $x (0; .+1);


Line 446: Line 442:


# The task:
# The task:
100, 1000, 10000 | meanfactorialdigits</lang>
100, 1000, 10000 | meanfactorialdigits</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 453: Line 449:
Mean proportion of zero digits in factorials to 10000 is 0.17300384824186707; goal (0.16) unmet.
Mean proportion of zero digits in factorials to 10000 is 0.17300384824186707; goal (0.16) unmet.
</pre>
</pre>

=={{header|Julia}}==
=={{header|Julia}}==
<lang julia>function meanfactorialdigits(N, goal = 0.0)
<syntaxhighlight lang="julia">function meanfactorialdigits(N, goal = 0.0)
factoril, proportionsum = big"1", 0.0
factoril, proportionsum = big"1", 0.0
for i in 1:N
for i in 1:N
Line 476: Line 471:


@time meanfactorialdigits(50000, 0.16)
@time meanfactorialdigits(50000, 0.16)
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Mean proportion of zero digits in factorials to 100 is 0.24675318616743216
Mean proportion of zero digits in factorials to 100 is 0.24675318616743216
Line 488: Line 483:
=== Base 1000 version ===
=== Base 1000 version ===
{{trans|Pascal, Phix}}
{{trans|Pascal, Phix}}
<lang julia>function init_zc()
<syntaxhighlight lang="julia">function init_zc()
zc = zeros(Int, 999)
zc = zeros(Int, 999)
for x in 1:9
for x in 1:9
Line 552: Line 547:
meanfactorialzeros(100, false)
meanfactorialzeros(100, false)
@time meanfactorialzeros()
@time meanfactorialzeros()
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
Mean proportion of zero digits in factorials to 100 is 0.24675318616743216
Mean proportion of zero digits in factorials to 100 is 0.24675318616743216
Line 560: Line 555:
4.638323 seconds (50.08 k allocations: 7.352 MiB)
4.638323 seconds (50.08 k allocations: 7.352 MiB)
</pre>
</pre>

=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ClearAll[ZeroDigitsFractionFactorial]
<syntaxhighlight lang="mathematica">ClearAll[ZeroDigitsFractionFactorial]
ZeroDigitsFractionFactorial[n_Integer] := Module[{m},
ZeroDigitsFractionFactorial[n_Integer] := Module[{m},
m = IntegerDigits[n!];
m = IntegerDigits[n!];
Line 576: Line 570:
means = Accumulate[N@fracs]/Range[Length[fracs]];
means = Accumulate[N@fracs]/Range[Length[fracs]];
len = LengthWhile[Reverse@means, # < 0.16 &];
len = LengthWhile[Reverse@means, # < 0.16 &];
50000 - len + 1</lang>
50000 - len + 1</syntaxhighlight>
{{out}}
{{out}}
<pre>0.111111
<pre>0.111111
Line 584: Line 578:
0.173004
0.173004
47332</pre>
47332</pre>

=={{header|Nim}}==
=={{header|Nim}}==


===Task===
===Task===
{{libheader|bignum}}
{{libheader|bignum}}
<lang Nim>import strutils, std/monotimes
<syntaxhighlight lang="nim">import strutils, std/monotimes
import bignum
import bignum


Line 604: Line 597:
lim *= 10
lim *= 10
echo()
echo()
echo getMonoTime() - t0</lang>
echo getMonoTime() - t0</syntaxhighlight>


{{out}}
{{out}}
Line 617: Line 610:
At each step, we eliminate the trailing zeroes to reduce the length of the number and save some time. But this is not much, about 8%.
At each step, we eliminate the trailing zeroes to reduce the length of the number and save some time. But this is not much, about 8%.


<lang Nim>import strutils, std/monotimes
<syntaxhighlight lang="nim">import strutils, std/monotimes
import bignum
import bignum


Line 638: Line 631:


echo "Permanently below 0.16 at n = ", first
echo "Permanently below 0.16 at n = ", first
echo "Execution time: ", getMonoTime() - t0</lang>
echo "Execution time: ", getMonoTime() - t0</syntaxhighlight>


{{out}}
{{out}}
<pre>Permanently below 0.16 at n = 47332
<pre>Permanently below 0.16 at n = 47332
Execution time: (seconds: 190, nanosecond: 215845101)</pre>
Execution time: (seconds: 190, nanosecond: 215845101)</pre>

=={{header|Pascal}}==
=={{header|Pascal}}==
Doing the calculation in Base 1,000,000,000 like in [[Primorial_numbers#alternative]].<BR>
Doing the calculation in Base 1,000,000,000 like in [[Primorial_numbers#alternative]].<BR>
The most time consuming is converting to string and search for zeros.<BR>
The most time consuming is converting to string and search for zeros.<BR>
Therefor I do not convert to string.I divide the base in sections of 3 digits with counting zeros in a lookup table.
Therefor I do not convert to string.I divide the base in sections of 3 digits with counting zeros in a lookup table.
<lang pascal>program Factorial;
<syntaxhighlight lang="pascal">program Factorial;
{$IFDEF FPC} {$MODE DELPHI} {$Optimization ON,ALL} {$ENDIF}
{$IFDEF FPC} {$MODE DELPHI} {$Optimization ON,ALL} {$ENDIF}
uses
uses
Line 836: Line 828:
inc(i);
inc(i);
writeln('First ratio < 0.16 ', i:8,SumOfRatio[i]/i:20:17);
writeln('First ratio < 0.16 ', i:8,SumOfRatio[i]/i:20:17);
end.</lang>
end.</syntaxhighlight>
{{out}}
{{out}}
<pre> 100 0.246753186167432
<pre> 100 0.246753186167432
Line 844: Line 836:
First ratio < 0.16 47332 0.15999999579985665
First ratio < 0.16 47332 0.15999999579985665
Real time: 4.898 s CPU share: 99.55 % // 2.67s on 2200G freepascal 3.2.2</pre>
Real time: 4.898 s CPU share: 99.55 % // 2.67s on 2200G freepascal 3.2.2</pre>

=={{header|Perl}}==
=={{header|Perl}}==
{{libheader|ntheory}}
{{libheader|ntheory}}
<lang perl>use strict;
<syntaxhighlight lang="perl">use strict;
use warnings;
use warnings;
use ntheory qw/factorial/;
use ntheory qw/factorial/;
Line 855: Line 846:
$f = factorial $_ and $sum += ($f =~ tr/0//) / length $f for 1..$n;
$f = factorial $_ and $sum += ($f =~ tr/0//) / length $f for 1..$n;
printf "%5d: %.5f\n", $n, $sum/$n;
printf "%5d: %.5f\n", $n, $sum/$n;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre> 100: 0.24675
<pre> 100: 0.24675
1000: 0.20354
1000: 0.20354
10000: 0.17300</pre>
10000: 0.17300</pre>

=={{header|Phix}}==
=={{header|Phix}}==
Using "string math" to create reversed factorials, for slightly easier skipping of "trailing" zeroes,
Using "string math" to create reversed factorials, for slightly easier skipping of "trailing" zeroes,
but converted to base 1000 and with the zero counting idea from Pascal, which sped it up threefold.
but converted to base 1000 and with the zero counting idea from Pascal, which sped it up threefold.
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">rfs</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}</span> <span style="color: #000080;font-style:italic;">-- reverse factorial(1) in base 1000</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">rfs</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}</span> <span style="color: #000080;font-style:italic;">-- reverse factorial(1) in base 1000</span>
Line 929: Line 919:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The mean proportion dips permanently below 0.16 at %d. (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">first</span><span style="color: #0000FF;">,</span><span style="color: #000000;">e</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The mean proportion dips permanently below 0.16 at %d. (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">first</span><span style="color: #0000FF;">,</span><span style="color: #000000;">e</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 940: Line 930:
=== trailing zeroes only ===
=== trailing zeroes only ===
Should you only be interested in the ratio of trailing zeroes, you can do that much faster:
Should you only be interested in the ratio of trailing zeroes, you can do that much faster:
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">t0</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">time</span><span style="color: #0000FF;">(),</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">t0</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">time</span><span style="color: #0000FF;">(),</span>
Line 968: Line 958:
<span style="color: #004080;">string</span> <span style="color: #000000;">e</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">e</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The mean proportion dips permanently below 0.07 at %d. (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">first</span><span style="color: #0000FF;">,</span><span style="color: #000000;">e</span><span style="color: #0000FF;">})</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The mean proportion dips permanently below 0.07 at %d. (%s)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">first</span><span style="color: #0000FF;">,</span><span style="color: #000000;">e</span><span style="color: #0000FF;">})</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 976: Line 966:
The mean proportion dips permanently below 0.07 at 31549. (0.1s)
The mean proportion dips permanently below 0.07 at 31549. (0.1s)
</pre>
</pre>

=={{header|Python}}==
=={{header|Python}}==
<lang python>def facpropzeros(N, verbose = True):
<syntaxhighlight lang="python">def facpropzeros(N, verbose = True):
proportions = [0.0] * N
proportions = [0.0] * N
fac, psum = 1, 0.0
fac, psum = 1, 0.0
Line 1,000: Line 989:


print("The mean proportion dips permanently below 0.16 at {}.".format(n + 2))
print("The mean proportion dips permanently below 0.16 at {}.".format(n + 2))
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
The mean proportion of 0 in factorials from 1 to 100 is 0.24675318616743216.
The mean proportion of 0 in factorials from 1 to 100 is 0.24675318616743216.
Line 1,008: Line 997:
</pre>
</pre>
The means can be plotted, showing a jump from 0 to over 0.25, followed by a slowly dropping curve:
The means can be plotted, showing a jump from 0 to over 0.25, followed by a slowly dropping curve:
<lang python>import matplotlib.pyplot as plt
<syntaxhighlight lang="python">import matplotlib.pyplot as plt
plt.plot([i+1 for i in range(len(props))], props)
plt.plot([i+1 for i in range(len(props))], props)
</syntaxhighlight>
</lang>
=== Base 1000 version ===
=== Base 1000 version ===
{{trans|Go via Phix via Pascal}}
{{trans|Go via Phix via Pascal}}
<lang python>def zinit():
<syntaxhighlight lang="python">def zinit():
zc = [0] * 999
zc = [0] * 999
for x in range(1, 10):
for x in range(1, 10):
Line 1,074: Line 1,063:
meanfactorialdigits()
meanfactorialdigits()
print("\nTotal time:", time.perf_counter() - TIME0, "seconds.")
print("\nTotal time:", time.perf_counter() - TIME0, "seconds.")
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
The mean proportion of zero digits in factorials to 100 is 0.24675318616743216
The mean proportion of zero digits in factorials to 100 is 0.24675318616743216
Line 1,083: Line 1,072:
Total time: 648.3583232999999 seconds.
Total time: 648.3583232999999 seconds.
</pre>
</pre>

=={{header|Raku}}==
=={{header|Raku}}==
Works, but depressingly slow for 10000.
Works, but depressingly slow for 10000.


<lang perl6>sub postfix:<!> (Int $n) { ( constant factorial = 1, 1, |[\*] 2..* )[$n] }
<syntaxhighlight lang="raku" line>sub postfix:<!> (Int $n) { ( constant factorial = 1, 1, |[\*] 2..* )[$n] }
sink 10000!; # prime the iterator to allow multithreading
sink 10000!; # prime the iterator to allow multithreading


Line 1,096: Line 1,084:
,1000
,1000
,10000
,10000
).map: -> \n { "{n}: {([+] (^n).map: *.&zs) / n}" }</lang>
).map: -> \n { "{n}: {([+] (^n).map: *.&zs) / n}" }</syntaxhighlight>
{{out}}
{{out}}
<pre>100: 0.24675318616743216
<pre>100: 0.24675318616743216
Line 1,102: Line 1,090:
10000: 0.17300384824186605
10000: 0.17300384824186605
</pre>
</pre>

=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program computes the mean of the proportion of "0" digits a series of factorials.*/
<syntaxhighlight lang="rexx">/*REXX program computes the mean of the proportion of "0" digits a series of factorials.*/
parse arg $ /*obtain optional arguments from the CL*/
parse arg $ /*obtain optional arguments from the CL*/
if $='' | $="," then $= 100 1000 10000 /*not specified? Then use the default.*/
if $='' | $="," then $= 100 1000 10000 /*not specified? Then use the default.*/
Line 1,134: Line 1,121:
do k=1 for z; != ! * k; y= y + countstr(0, !) / length(!)
do k=1 for z; != ! * k; y= y + countstr(0, !) / length(!)
end /*k*/
end /*k*/
return y/z</lang>
return y/z</syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>
Line 1,144: Line 1,131:
───────────┴────────────────────────────────────────────────────────────────────────────────
───────────┴────────────────────────────────────────────────────────────────────────────────
</pre>
</pre>

=={{header|Rust}}==
=={{header|Rust}}==
{{trans|Phix}}
{{trans|Phix}}
<lang rust>fn init_zc() -> Vec<usize> {
<syntaxhighlight lang="rust">fn init_zc() -> Vec<usize> {
let mut zc = vec![0; 1000];
let mut zc = vec![0; 1000];
zc[0] = 3;
zc[0] = 3;
Line 1,232: Line 1,218:
duration.as_millis()
duration.as_millis()
);
);
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,241: Line 1,227:
The mean proportion dips permanently below 0.16 at 47332. (4485ms)
The mean proportion dips permanently below 0.16 at 47332. (4485ms)
</pre>
</pre>

=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>func mean_factorial_digits(n, d = 0) {
<syntaxhighlight lang="ruby">func mean_factorial_digits(n, d = 0) {


var v = 1
var v = 1
Line 1,258: Line 1,243:
say mean_factorial_digits(100)
say mean_factorial_digits(100)
say mean_factorial_digits(1000)
say mean_factorial_digits(1000)
say mean_factorial_digits(10000)</lang>
say mean_factorial_digits(10000)</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,265: Line 1,250:
0.173003848241866053180036642893070615681027880906
0.173003848241866053180036642893070615681027880906
</pre>
</pre>

=={{header|Wren}}==
=={{header|Wren}}==
===Brute force===
===Brute force===
Line 1,271: Line 1,255:
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
Very slow indeed, 10.75 minutes to reach N = 10,000.
Very slow indeed, 10.75 minutes to reach N = 10,000.
<lang ecmascript>import "/big" for BigInt
<syntaxhighlight lang="ecmascript">import "/big" for BigInt
import "/fmt" for Fmt
import "/fmt" for Fmt


Line 1,286: Line 1,270:
Fmt.print("$,6d = $12.10f", n, sum / n)
Fmt.print("$,6d = $12.10f", n, sum / n)
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,299: Line 1,283:
{{trans|Phix}}
{{trans|Phix}}
Around 60 times faster than before with 10,000 now being reached in about 10.5 seconds. Even the stretch goal is now viable and comes in at 5 minutes 41 seconds.
Around 60 times faster than before with 10,000 now being reached in about 10.5 seconds. Even the stretch goal is now viable and comes in at 5 minutes 41 seconds.
<lang ecmascript>import "/fmt" for Fmt
<syntaxhighlight lang="ecmascript">import "/fmt" for Fmt


var rfs = [1] // reverse factorial(1) in base 1000
var rfs = [1] // reverse factorial(1) in base 1000
Line 1,364: Line 1,348:
Fmt.write("$,6d = $12.10f", first, firstRatio)
Fmt.write("$,6d = $12.10f", first, firstRatio)
System.print(" (stays below 0.16 after this)")
System.print(" (stays below 0.16 after this)")
Fmt.print("$,6d = $12.10f", 50000, total/50000)</lang>
Fmt.print("$,6d = $12.10f", 50000, total/50000)</syntaxhighlight>


{{out}}
{{out}}