Average loop length: Difference between revisions

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