41 lines
871 B
Text
41 lines
871 B
Text
sub ListProperDivisors(limit)
|
|
if limit < 1 then return : fi
|
|
for i = 1 to limit
|
|
print i, " ->";
|
|
if i = 1 then
|
|
print " (None)"
|
|
continue //for
|
|
endif
|
|
for j = 1 to int(i / 2)
|
|
if mod(i, j) = 0 then print " ", j; : fi
|
|
next j
|
|
print
|
|
next i
|
|
end sub
|
|
|
|
sub CountProperDivisors(number)
|
|
if number < 2 then return 0 : fi
|
|
count = 0
|
|
for i = 1 to int(number / 2)
|
|
if mod(number, i) = 0 then count = count + 1 : fi
|
|
next i
|
|
return count
|
|
end sub
|
|
|
|
most = 1
|
|
maxCount = 0
|
|
|
|
print "The proper divisors of the following numbers are: \n"
|
|
ListProperDivisors(10)
|
|
|
|
for n = 2 to 20000
|
|
count = CountProperDivisors(n)
|
|
if count > maxCount then
|
|
maxCount = count
|
|
most = n
|
|
endif
|
|
next n
|
|
|
|
print
|
|
print most, " has the most proper divisors, namely ", maxCount
|
|
end
|