So, if any of you are MS Excel gurus, or can program in Visual Basic, I made a simple prime-checking funcion in VB earlier today.

If anyone wants, I can give a more detailed explanation of how to use this in Excel.

It becomes highly unstable for integers > 2,147,483,468, but will occassionally* work for such integers.

*-In 8 attempts, 3 times I got it to correctly return a prime greater than the above number. In all 8 attempts, Excel crashed and had to be rebooted.

All you need to know about calling/using the function is that it is named "isPrime" and needs a number (any number will do) to work properly.

*What follows is all code; copy it and paste in a new module in Excel's VB editor. Compile it and you are good to go!*

Function IsPrime(Num)

'For integers > 2,147,483,468 the function becomes unstable.

Dim i As Long

i = 3

Dim pTest As Boolean

pTest = True

Dim limit As Long

If Num < 6 Then

limit = 3

Else: limit = Num \ 2

End If

Dim N As Long

If Num < 2 Then

N = 1

ElseIf Num <> Round(Num, 0) Then

N = 1

Else: N = Num

End If

If N = 1 Then

pTest = False

ElseIf N Mod 2 = 0 And N > 2 Then

pTest = False

Else: Do While i <= limit

If N = i Then

Exit Do

ElseIf N Mod i = 0 Then

pTest = False

Exit Do

End If

i = i + 2

Loop

End If

IsPrime = pTest

End Function