ISPRIME
Public Function ISPRIME(ByVal lNumber As Long) As Boolean
Dim i As Long
ISPRIME = True
For i = 2 To Application.RoundDown(Math.Sqr(lNumber), 0)
If (lNumber Mod i = 0) Then
ISPRIME = False
Exit For
End If
Next i
End Function
As an excel formula
=NOT(OR(MOD(A1,SEQUENCE(ROUNDDOWN(SQRT(A1),0)-1,,2))=0))
© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited TopPrevNext