Code: Select all
'"lofac" is my own invention. The function returns the lowest factor.
inspired by https://en.wikipedia.org/wiki/Primality_test
type myint as integer
function lofac(i as myint) as myint
if i<4 then return 1
if (i and 1)=0 then return 2
var n=3
while n*n <= i
if i mod n = 0 then return n
n += 2
Wend
return 1
End Function
for i as long = 2 to 99
if lofac(i)=1 then ? i; " ";
Next
?
?
? lofac(57)
sleep