28 lines
650 B
Text
28 lines
650 B
Text
val getproper = fn(x) { for[=[]] i of x \ 2 { if x div i: _for ~= [i] } }
|
|
val cntproper = fn(x) { for[=0] i of x \ 2 { if x div i: _for += 1 } }
|
|
|
|
val listproper = fn(x) {
|
|
if x < 1: return null
|
|
for[=""] i of x {
|
|
_for ~= "{{i:2}} -> {{getproper(i)}}\n"
|
|
}
|
|
}
|
|
|
|
writeln "The proper divisors of the following numbers are :"
|
|
writeln listproper(10)
|
|
|
|
exit 0
|
|
|
|
var mx = 0
|
|
var most = []
|
|
for n in 2 .. 20_000 {
|
|
val cnt = cntproper(n)
|
|
if cnt == mx {
|
|
most = more(most, n)
|
|
} else if cnt > mx {
|
|
mx, most = cnt, [n]
|
|
}
|
|
}
|
|
|
|
writeln "The following number(s) <= 20000 have the most proper divisors ({{max}})"
|
|
writeln most
|