Checks to see if a number is a primary number. Prime numbers are commonly found in encryption schemes that use Public/Private keys.
By: Lewis Moten
Function IsPrime(ByRef pLngNumber)
Dim lLngSquare, lLngIndex
IsPrime = False
if pLngNumber < 2 Then Exit function
if pLngNumber Mod 2 = 0 Then Exit function
lLngSquare = Sqr(pLngNumber)
For lLngIndex = 3 To lLngSquare Step 2
if pLngNumber Mod lLngIndex = 0 Then Exit function
Next
IsPrime = True
End function
Dim lLngSquare, lLngIndex
IsPrime = False
if pLngNumber < 2 Then Exit function
if pLngNumber Mod 2 = 0 Then Exit function
lLngSquare = Sqr(pLngNumber)
For lLngIndex = 3 To lLngSquare Step 2
if pLngNumber Mod lLngIndex = 0 Then Exit function
Next
IsPrime = True
End function
pLngNumber
Views 5,104
Downloads 1,532
CodeID
DB ID
ANmarAmdeen
609
Revisions
v1.0
Wednesday
July
25
2018