Distribution of 0 digits in factorial series: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Thundergnat moved page Distribution of 0 Digits in factorial series to Distribution of 0 digits in factorial series) |
(Added Sidef) |
||
Line 1,240: | Line 1,240: | ||
Mean proportion of zero digits in factorials to 10000 is 0.1730038482. (149ms) |
Mean proportion of zero digits in factorials to 10000 is 0.1730038482. (149ms) |
||
The mean proportion dips permanently below 0.16 at 47332. (4485ms) |
The mean proportion dips permanently below 0.16 at 47332. (4485ms) |
||
</pre> |
|||
=={{header|Sidef}}== |
|||
<lang ruby>func mean_factorial_digits(n, d = 0) { |
|||
var v = 1 |
|||
var total = 0.float |
|||
for k in (1..n) { |
|||
v *= k |
|||
total += v.digits.count(d)/v.len |
|||
} |
|||
total / n |
|||
} |
|||
say mean_factorial_digits(100) |
|||
say mean_factorial_digits(1000) |
|||
say mean_factorial_digits(10000)</lang> |
|||
{{out}} |
|||
<pre> |
|||
0.246753186167432217778415887197352699112940703327 |
|||
0.203544551103164635640043803171145530298574116789 |
|||
0.173003848241866053180036642893070615681027880906 |
|||
</pre> |
</pre> |
||