Public Function PreviousPrime( _ ByVal vX As Variant _ ) As Variant
PreviousPrime(-6) = -7 PreviousPrime(-5) = -7 PreviousPrime(-3) = -5 PreviousPrime(-2) = -3 PreviousPrime(-1) = -2 PreviousPrime(1) = -2 PreviousPrime(2) = -2 PreviousPrime(3) = 2 PreviousPrime(5) = 3 PreviousPrime(7) = 5See also:
PreviousPrimeSample Subroutine NextPrime Function NthPrime Function IsPrime FunctionvX: The number whose next smaller prime number is returned. Function returns Null if vX is Null or cannot be fixed up to a number.
Special handling:
If -3 < X <= -2 Then Return -3. If -2 < X <= 2 Then Return -2. If 2 < X <= 3 Then Return 2. If 3 < X <= 5 Then Return 3.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.