#### IsPrime – Determine whether a number is prime

‘ Return True if the number is primeFunction IsPrime(ByVal number As Long) As Boolean ‘ manually test 2 and 3 If number > 3 Then If number Mod 2 =

May 27, 2000

‘ Return True if the number is primeFunction IsPrime(ByVal number As Long) As Boolean ‘ manually test 2 and 3 If number > 3 Then If number Mod 2 =

May 27, 2000

‘ number of permutations of N objects in groups of M” Note: requires the FACTORIAL routineFunction Permutations(ByVal Objects As Long, ByVal GroupSize As Long) As Double Permutations = Factorial(Objects) /

May 27, 2000

‘ The factorial of a number” if NUMBER is negative or >170 it raises an’ “subscript out of range” errorFunction Factorial(ByVal number As Long) As Double Static result(170) As Double

May 27, 2000

‘ the Greatest Common Divisor of two integers’ (it uses the Euclide’s algorithm)’ if either argument is zero you get a “Division by Zero” errorFunction GCD(ByVal n1 As Long, ByVal

May 27, 2000

‘ A random number in the range (low, high)Function Rnd2(low As Single, high As Single) As Single Rnd2 = Rnd * (high – low) + lowEnd Function

May 27, 2000

‘ number of Combinations of N objects in groups of M” Note: requires the FACTORIAL routineFunction Combinations(ByVal Objects As Long, ByVal GroupSize As Long) As Double Combinations = (Factorial(Objects) /

May 27, 2000

‘ the Least Common Multiple of two integers’ (it uses the Euclide’s algorithm)’ if either argument is zero you get a “Division by Zero” error” Note: if your app also

May 27, 2000

‘ The fractional part of a floating-point number’ note that negative numbers return negative valuesFunction Fract(number As Variant) As Variant Fract = number – Fix(number)End Function

May 27, 2000

‘ Base 10 logarithmFunction Log10(number As Double) As Double Log10 = Log(number) / 2.30258509299405End Function