sub propdivsum (\x) { my @l = 1 if x > 1; (2 .. x.sqrt.floor).map: -> \d { unless x % d { @l.push: d; my \y = x div d; @l.push: y if y != d } } sum @l } say bag (1..20000).map: { propdivsum($_) <=> $_ }
Bag(Less(15043), More(4953), Same(4))
Last updated 11 months ago