Distribution of 0 digits in factorial series: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: rewrite the function to strictly comply with the task's requirements, simplified the code.)
Line 227: Line 227:


do j=1 for #; n= word($, j) /*calculate some factorial ranges. */
do j=1 for #; n= word($, j) /*calculate some factorial ranges. */
say center( commas(n), 11)'│' left(0dist(n), 75)... /*show results for above range.*/
p= 0dist(n) /* " the proportion of zeros. */
say center( commas(n), 11)'│' left(p/n, 75)... /*display the results for above range. */
end /*j*/
end /*j*/


Line 236: Line 235:
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
0dist: procedure; parse arg target; != 1; y= 0
0dist: procedure; parse arg z; != 1; y= 0
do k=1 for target; != ! * k; z= countstr(0, !); y= y+ z/length(!)
do k=1 for z; != ! * k; y= y + countstr(0, !) / length(!)</lang>
end /*k*/
return y</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
<pre>