Anonymous user
Average loop length: Difference between revisions
Replaced "strfmt" by "strformat" which is now equivalent but standard. Replaced the deprecated "random(n)" by "rand(n - 1)".
MaiconSoft (talk | contribs) No edit summary |
(Replaced "strfmt" by "strformat" which is now equivalent but standard. Replaced the deprecated "random(n)" by "rand(n - 1)".) |
||
Line 1,356:
=={{header|Nim}}==
{{trans|C}}
<lang nim>import random, math,
randomize()
Line 1,380:
inc result
bits = bits or x
x = 1 shl
echo " n\tavg\texp.\tdiff"
Line 1,389:
let theory = expected(n)
let diff = (avg / theory - 1) * 100
{{out}}
<pre> n avg exp. diff
|