Skip to content

Instantly share code, notes, and snippets.

/a_d_b.p6 Secret

Created June 1, 2017 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c8aef88bd4feabd2a4097b538da411bd to your computer and use it in GitHub Desktop.
Save anonymous/c8aef88bd4feabd2a4097b538da411bd to your computer and use it in GitHub Desktop.
# 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