-
-
Save anonymous/c8aef88bd4feabd2a4097b538da411bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://rosettacode.org/wiki/Abundant,_deficient_and_perfect_number_classifications#Perl_6 | |
sub propdivsum (\x) { | |
[+] flat(x > 1, gather for 2 .. x.sqrt.floor -> \d { | |
my \y = x div d; | |
if y * d == x { take d; take y unless y == d } | |
}) | |
} | |
say bag map { propdivsum($) <=> $_}, 1..20000 | |
# produces error: | |
# | |
# Use of uninitialized value of type Any in numeric context | |
# in sub propdivsum at a_d_p-nums.p6 line 4 | |
# No such method 'sqrt' for invocant of type 'Any' | |
# in sub propdivsum at a_d_p-nums.p6 line 5 | |
# in block <unit> at a_d_p-nums.p6 line 11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment