1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| '=======================================================================
'teste de restitution en tableau
Function NBP2(max, T) As Variant
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: NBP2 = Application.Transpose(Split(sc.Run("NBP", max), ",")): T = Timer - T
End Function
Sub test2()
Dim T
resultat = NBP2(100000, T)
Debug.Print UBound(resultat)
Debug.Print "temps ecoulé " & T & " secondes"
ActiveCell.Resize(UBound(resultat), 1).Value = resultat
End Sub |
Partager