1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Sub test2()
Dim T
Set resultat = NBP2(100000, T)
a = FunCount(resultat)
For I = 0 To a
Debug.Print NBP3(resultat, I)
Next
End Sub
'=======================================================================
'teste de restitution en tableau
Function NBP2(max, T) As Object
Set sc = CreateObject("ScriptControl")
code = code & "function NBP(max){var keys= new Array(); var a = 0;for(i = 2; i <= max; i++) {var j = 1;var racine = Math.floor(Math.sqrt(i));"
code = code & "do {j++;} while(j <= racine && i%j != 0);if(j > racine) {keys.push(a);keys[a]=i;a=a+1; }};return keys}"
With sc: .Language = "JScript": .AddCode code: End With
T = Timer: Set NBP2 = sc.Run("NBP", max): T = Timer - T
End Function
Function NBP3(T, I)
Set sc = CreateObject("ScriptControl")
code = code & "function NBP(T,i){return T[i]}"
With sc: .Language = "JScript": .AddCode code: End With
NBP3 = sc.Run("NBP", T, I)
End Function
Function FunCount(T)
Set sc = CreateObject("ScriptControl")
code = code & "function NBPCount(T){return T.length}"
With sc: .Language = "JScript": .AddCode code: End With
FunCount = sc.Run("NBPCount", T)
End Function |
Partager