Average loop length: Difference between revisions
Content added Content deleted
Line 3,165: | Line 3,165: | ||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
Ported from the VBA version |
Ported from the VBA version. I added some precalculations to speed it up |
||
<lang vb> |
<lang vb> |
||
Const MAX = 20 |
Const MAX = 20 |
||
Line 3,188: | Line 3,188: | ||
count = count + 1 |
count = count + 1 |
||
bits = bits Or x |
bits = bits Or x |
||
x = |
x =shift(Int(n * Rnd())) |
||
Loop |
Loop |
||
Next |
Next |
||
Line 3,196: | Line 3,196: | ||
function rf(v,n,s) rf=right(string(n,s)& v,n):end function |
function rf(v,n,s) rf=right(string(n,s)& v,n):end function |
||
'some precalculations to speed things up... |
|||
dim fact(20) |
|||
fact( |
dim fact(20),shift(20) |
||
fact(0)=1:shift(0)=1 |
|||
⚫ | |||
for i=1 to 20 |
|||
⚫ | |||
shift(i)=2*shift(i-1) |
|||
next |
|||
Dim n |
Dim n |
||
Line 3,237: | Line 3,241: | ||
20 5.2906 5.2936 ( 0.0006%) |
20 5.2906 5.2936 ( 0.0006%) |
||
</pre> |
</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{trans|Go}} |
{{trans|Go}} |