Skip to main content
added 49 characters in body
Source Link
scpchicken
  • 783
  • 5
  • 12

Raku, 25 2323 22 bytes

thanks ovs for 2 byte improvement
also JoKing for 1 byte improvement

{sum grep( $_%%*,1..$_).sum}
declare anonymous block ($_ implicitly declared)
filter (grep) numbers from 1 to $_ inclusive using the whatever variable (*) that are divisible by $_
get the sum of that list

Try it online!

Raku, 25 23 bytes

thanks ovs for 2 byte improvement

{grep($_%%*,1..$_).sum}
declare anonymous block ($_ implicitly declared)
filter (grep) numbers from 1 to $_ inclusive using the whatever variable (*) that are divisible by $_
get the sum of that list

Try it online!

Raku, 25 23 22 bytes

thanks ovs for 2 byte improvement
also JoKing for 1 byte improvement

{sum grep $_%%*,1..$_}
declare anonymous block ($_ implicitly declared)
filter (grep) numbers from 1 to $_ inclusive using the whatever variable (*) that are divisible by $_
get the sum of that list

Try it online!

deleted 173 characters in body
Source Link
scpchicken
  • 783
  • 5
  • 12

Raku, 2525 23 bytes

thanks ovs for 2 byte improvement

{grep($_%%*,1..$_).grep($_%%*).sum}
declare anonymous block
iterate over 1 to implicit parameter ($_ isimplicitly declared when using block) inclusive
filter (grep) allnumbers thefrom range1 numbersto $_ inclusive using the whatever variable (*) that are divisible by $_
get the sum of that list

Alternative 25

{^$_ .grep($_%%*).sum+$_}
^$_ will give you the range (0..$_ - 1) and then you just add $_ to the end

Try it online!

Raku, 25 bytes

{(1..$_).grep($_%%*).sum}
declare anonymous block
iterate over 1 to implicit parameter ($_ is declared when using block) inclusive
filter (grep) all the range numbers using the whatever variable (*) that are divisible by $_
get the sum of that list

Alternative 25

{^$_ .grep($_%%*).sum+$_}
^$_ will give you the range (0..$_ - 1) and then you just add $_ to the end

Try it online!

Raku, 25 23 bytes

thanks ovs for 2 byte improvement

{grep($_%%*,1..$_).sum}
declare anonymous block ($_ implicitly declared)
filter (grep) numbers from 1 to $_ inclusive using the whatever variable (*) that are divisible by $_
get the sum of that list

Try it online!

Source Link
scpchicken
  • 783
  • 5
  • 12

Raku, 25 bytes

{(1..$_).grep($_%%*).sum}
declare anonymous block
iterate over 1 to implicit parameter ($_ is declared when using block) inclusive
filter (grep) all the range numbers using the whatever variable (*) that are divisible by $_
get the sum of that list

Alternative 25

{^$_ .grep($_%%*).sum+$_}
^$_ will give you the range (0..$_ - 1) and then you just add $_ to the end

Try it online!