Proper divisors: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: using .deepmap to flatten) |
|||
Line 1,081: | Line 1,081: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{Works with|rakudo|2015-10-31}} |
|||
<lang perl6>sub propdiv (\x) { |
<lang perl6>sub propdiv (\x) { |
||
(1 if x > 1), gather for 2 .. x.sqrt.floor -> \d { |
my @l =(1 if x > 1), gather for 2 .. x.sqrt.floor -> \d { |
||
my \y = x div d; |
my \y = x div d; |
||
if y * d == x { take d; take y unless y == d } |
if y * d == x { take d; take y unless y == d } |
||
} |
} |
||
gather @l.deepmap(*.take); |
|||
} |
} |
||