Código (vb) [Seleccionar]
Private Sub Form_Load()
Form1.Show
Form1.AutoRedraw = True
MsgBox "empezara luego del ok"
t = Timer
For x = 0 To 100000
Call mul5and3below1000
Next
Form1.Print "tiempo 7913 " & Timer - t
Form1.Print "resultado 7913 " & mul5and3below1000
t = Timer
For x = 0 To 100000
Call mul_3_5
Next
Form1.Print "Tiempo dany " & Timer - t
Form1.Print "Resultado dani " & mul_3_5
End Sub
Private Function mul5and3below1000() As Long
Dim ct As Long
Dim aux As Long
Do
mul5and3below1000 = mul5and3below1000 + aux + aux2
ct = ct + 1
aux = ct + ct + ct
aux2 = ct + ct + ct + ct + ct
Loop While aux2 < 1000
Do
mul5and3below1000 = mul5and3below1000 + aux
ct = ct + 1
aux = ct + ct + ct
Loop While aux < 1000
ct = 0
aux = 0
Do
mul5and3below1000 = mul5and3below1000 - aux
ct = ct + 1
aux = ct + ct + ct + ct + ct + ct + ct + ct + ct + ct + ct + ct + ct + ct + ct
Loop While aux < 1000
End Function
Function mul_3_5() As Long
Dim i As Integer
For i = 1 To 999
If (i Mod 3) < 1 Or (i Mod 5) < 1 Then
mul_3_5 = mul_3_5 + i
End If
Next i
End Function
Ok, con esta funcion de testeo los resultados mios son: