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


Public

Tested

My Own Work
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

pLngNumber

Views 3875 Downloads 1162

Classic ASP Math
ANmarAmdeen
655
Revisions

v1.0