gambas-source-code/benchmark/primes.gbs
Benoît Minisini 3cf59d321a [DEVELOPMENT ENVIRONMENT]
* NEW: Files can be dropped from files managers to the project treeview.
  They are automatically inserted into the project then.

[WIKI CGI SCRIPT]
* BUG: '{' and '}' are not interpreted anymore between '=='.

[BENCHMARKS]
* NEW: Add Gambas/Perl/Python benchmarks to the repository.

[INTERPRETER]
* NEW: A Stop instruction encountered inside a component is not ignored
  anymore and stops the program.
* BUG: Fix the File.SetName, File.SetExt and File.SetBaseName methods.

[COMPILER]
* NEW: The preprocessor now undestands the False and True constants.

[GB.FORM]
* NEW: Clean up the Stock class icon loading algorithm.
* BUG: Fix the Gnome icon map.

[GB.FORM.STOCK]
* NEW: Support for svg stock icons.

[GB.QT4]
* BUG: Drag.Show() now works for DnD operations started outside of the 
  application.

[GB.GTK]
* BUG: Drag.Show() now works for DnD operations started outside of the 
  application.


git-svn-id: svn://localhost/gambas/trunk@3400 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2010-12-27 14:28:59 +00:00

56 lines
749 B
Text
Executable file

#!/usr/bin/env gbs3
Sub GetPrimes(N As Integer) As Integer[]
Dim aRes As New Integer[]
Dim S As Integer[]
Dim I, J, M As Integer
Dim iMRoot, iHalf As Integer
If N < 2 Then Return aRes
If N = 2 Then Return [ 2 ]
S = New Integer[(N - 3 + 1) \ 2]
For J = 3 To N Step 2
S[I] = J
Inc I
Next
iMRoot = Sqr(N)
iHalf = S.Count
I = 0
M = 3
While M <= iMRoot
If S[I] Then
J = (M * M - 3) \ 2
S[J] = 0
While J < iHalf
S[J] = 0
J += M
Wend
Endif
Inc I
M = 2 * I + 3
Wend
aRes.Add(2)
For Each I In S
If I Then aRes.Add(I)
Next
Return aRes
End
Dim aRes As Integer[]
Dim I As Integer
For I = 1 To 10
aRes = GetPrimes(10000000)
Print aRes.Count
Next