Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module PrimeSum 'My solution to Project Euler Problem 10
- Sub Main()
- Dim tbl() As Boolean = PSieve(2000000)
- Dim sum As Double = 0
- For i = 0 To tbl.Length - 1
- If Not tbl(i) Then sum += i
- Next
- Console.WriteLine(sum)
- End Sub
- Function PSieve(ByVal limit As Integer) As Boolean()
- Dim input(limit) As Boolean
- input(0) = True : input(1) = True
- Parallel.For(2, CInt(Math.Sqrt(input.Length)), Sub(i)
- If Not input(i) Then
- Dim j As Integer = 2 * i
- While j <= input.Length - 1
- input(j) = True
- j += i
- End While
- End If
- End Sub)
- Return input
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement