# May 27, 2000

#### 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 =

#### Permutations – Number of permutations of N objects in groups of M

‘ 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) /

#### Factorial – The factorial of a number

‘ 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

#### GCD – The Greatest Common Divisor of two integers

‘ 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

#### Rnd2 – A random value in a range

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

#### Combinations – The number of combinations of N objects in groups of N

‘ 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) /

#### LCM – The Least Common Multiple of two integers

‘ 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

#### Fract – The fractional portion of a number

‘ 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

#### Log10 – Base-10 logarithm

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