Jump to content

Distribution of 0 digits in factorial series: Difference between revisions

m
→‎{{header|REXX}}: rewrite the function to strictly comply with the task's requirements, simplified the code.
m (→‎{{header|REXX}}: rewrite the function to strictly comply with the task's requirements, simplified the code.)
Line 227:
 
do j=1 for #; n= word($, j) /*calculate some factorial ranges. */
say center( commas(n), 11)'│' left(p/0dist(n), 75)... /*display theshow 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*/
 
Line 236 ⟶ 235:
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
/*──────────────────────────────────────────────────────────────────────────────────────*/
0dist: procedure; parse arg targetz; != 1; y= 0
do k=1 for targetz; != ! * k; z y= y + countstr(0, !); y= y+ z/ length(!)</lang>
end /*k*/
return y</lang>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.