IsPrime

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

Parameters

pLngNumber

Views 141 Downloads 70

Perm link