Proper divisors: Difference between revisions

Added uBasic/4tH version
No edit summary
(Added uBasic/4tH version)
Line 6,233:
</pre>
 
=={{header|uBasic/4tH}}==
{{trans|True BASIC}}
<lang>LET m = 1
LET c = 0
PRINT "The proper divisors of the following numbers are:\n"
PROC _ListProperDivisors (10)
FOR n = 2 TO 20000
LET d = FUNC(_CountProperDivisors(n))
IF d > c THEN
LET c = d
LET m = n
ENDIF
NEXT
PRINT
PRINT m; " has the most proper divisors, namely "; c
END
 
_CountProperDivisors
PARAM (1)
LOCAL (2)
IF a@ < 2 THEN RETURN (0)
LET c@ = 0
FOR b@ = 1 TO a@ / 2
IF a@ % b@ = 0 THEN LET c@ = c@ + 1
NEXT
RETURN (c@)
_ListProperDivisors
PARAM (1)
LOCAL (2)
 
IF a@ < 1 THEN RETURN
FOR b@ = 1 TO a@
PRINT b@; " ->";
IF b@ = 1 THEN PRINT " (None)";
FOR c@ = 1 TO b@ / 2
IF b@ % c@ = 0 THEN PRINT " "; c@;
NEXT
PRINT
NEXT
RETURN</lang>
{{Out}}
<pre>The proper divisors of the following numbers are:
 
1 -> (None)
2 -> 1
3 -> 1
4 -> 1 2
5 -> 1
6 -> 1 2 3
7 -> 1
8 -> 1 2 4
9 -> 1 3
10 -> 1 2 5
 
15120 has the most proper divisors, namely 79
 
0 OK, 0:415</pre>
=={{header|VBA}}==
<lang vb>Public Sub Proper_Divisor()
374

edits