Following ia a useful function for determining whether or not one number is a factor of another.
Function isFactor( number as Integer, factor as Integer) as Boolean
'''' Is c a factor of a ?
'''' Return true if c divides evenly into a, with no remainder.
Dim yesno as Boolean
if (a mod c) = 0 then
yesno= true ' Remainder is zero - it IS a factor.
else
yesno= false
end if
return yesno
End Function