33 lines
708 B
Text
33 lines
708 B
Text
func PropDiv(N, Show); \Count and optionally show proper divisors of N
|
|
int N, Show, D, C;
|
|
[C:= 0;
|
|
if N > 1 then
|
|
[D:= 1;
|
|
repeat if rem(N/D) = 0 then
|
|
[C:= C+1;
|
|
if Show then
|
|
[if D > 1 then ChOut(0, ^ );
|
|
IntOut(0, D);
|
|
];
|
|
];
|
|
D:= D+1;
|
|
until D >= N;
|
|
];
|
|
return C;
|
|
];
|
|
|
|
int N, SN, Cnt, Max;
|
|
[for N:= 1 to 10 do
|
|
[ChOut(0, ^[); PropDiv(N, true); ChOut(0, ^]);
|
|
ChOut(0, ^ );
|
|
];
|
|
CrLf(0);
|
|
|
|
Max:= 0;
|
|
for N:= 1 to 20000 do
|
|
[Cnt:= PropDiv(N, false);
|
|
if Cnt > Max then
|
|
[Max:= Cnt; SN:= N];
|
|
];
|
|
IntOut(0, SN); ChOut(0, ^ ); IntOut(0, Max); CrLf(0);
|
|
]
|