Skip to main content
3 of 3
added 49 characters in body
scpchicken
  • 783
  • 5
  • 12

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!

scpchicken
  • 783
  • 5
  • 12