35 lines
958 B
Text
35 lines
958 B
Text
100 cls
|
|
110 most = 1
|
|
120 maxcount = 0
|
|
130 print "The proper divisors of the following numbers are: ";chr$(10)
|
|
140 listproperdivisors(10)
|
|
150 for n = 2 to 20000
|
|
160 rem It is extremely slow in this loop
|
|
170 count = countproperdivisors(n)
|
|
180 if count > maxcount then
|
|
190 maxcount = count
|
|
200 most = n
|
|
210 endif
|
|
220 next n
|
|
230 print
|
|
240 print most;" has the most proper divisors, namely ";maxcount
|
|
250 end
|
|
260 function countproperdivisors(number)
|
|
270 if number < 2 then countproperdivisors = 0
|
|
280 count = 0
|
|
290 for i = 1 to int(number/2)
|
|
300 if number mod i = 0 then count = count+1
|
|
310 next i
|
|
320 countproperdivisors = count
|
|
330 end function
|
|
340 sub listproperdivisors(limit)
|
|
350 if limit < 1 then exit sub
|
|
360 for i = 1 to limit
|
|
370 print using "## ->";i;
|
|
380 if i = 1 then print " (None)";
|
|
390 for j = 1 to int(i/2)
|
|
400 if i mod j = 0 then print " ";j;
|
|
410 next j
|
|
420 print
|
|
430 next i
|
|
440 end sub
|