Skip to main content
4 of 4
added 20 characters in body
ophact
  • 3.2k
  • 1
  • 7
  • 24

JavaScript (Node.js), 61 bytes

N=>eval('for(k=n=0;n++<N;)for(c=e=N%n||n;c<=e+N-n;)k+=c*c++')

Try it online!

-2 by Polichinelle.

Iteratively calculates sum, which is shorter than direct calculation.

ophact
  • 3.2k
  • 1
  • 7
  • 24