RosettaCodeData/Task/Proper-divisors/BASIC256/proper-divisors.basic

43 lines
746 B
Plaintext

subroutine ListProperDivisors(limit)
if limit < 1 then return
for i = 1 to limit
print i; " ->";
if i = 1 then
print " (None)"
continue for
end if
for j = 1 to i \ 2
if i mod j = 0 then print " "; j;
next j
print
next i
end subroutine
function CountProperDivisors(number)
if number < 2 then return 0
dim cont = 0
for i = 1 to number \ 2
if number mod i = 0 then cont += 1
next i
return cont
end function
most = 1
maxCount = 0
print "The proper divisors of the following numbers are:"
print
call ListProperDivisors(10)
for n = 2 to 20000
cont = CountProperDivisors(n)
if cont > maxCount then
maxCount = cont
most = n
end if
next n
print
print most; " has the most proper divisors, namely "; maxCount
end