|
|
|
Click here to copy the following block |
Function GetPrimeNumbers(numberOfPrimes As Long) As Long() Dim found As Long Dim n As Long Dim i As Long If numberOfPrimes <= 0 Then Err.Raise 1002, , "Invalid argument" ReDim result(1 To numberOfPrimes) As Long result(1) = 2: found = 1 n = 1 Do n = n + 2 For i = 1 To found If (n Mod result(i)) = 0 Then Exit For Next If i > found Then found = found + 1 result(found) = n If found = numberOfPrimes Then Exit Do End If Loop GetPrimeNumbers = result End Function |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|