document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. Module PrimeSum \'My solution to Project Euler Problem 10
  2.     Sub Main()
  3.         Dim tbl() As Boolean = PSieve(2000000)
  4.         Dim sum As Double = 0
  5.         For i = 0 To tbl.Length - 1
  6.             If Not tbl(i) Then sum += i
  7.         Next
  8.         Console.WriteLine(sum)
  9.     End Sub
  10.     Function PSieve(ByVal limit As Integer) As Boolean()
  11.         Dim input(limit) As Boolean
  12.         input(0) = True : input(1) = True
  13.         Parallel.For(2, CInt(Math.Sqrt(input.Length)), Sub(i)
  14.                                                            If Not input(i) Then
  15.                                                                Dim j As Integer = 2 * i
  16.                                                                While j <= input.Length - 1
  17.                                                                    input(j) = True
  18.                                                                    j += i
  19.                                                                End While
  20.                                                            End If
  21.                                                        End Sub)
  22.         Return input
  23.     End Function
  24. End Module
');