# [JavaScript (Node.js)], 78 bytes <!-- language-all: lang-javascript --> N=>eval('for(k=n=0;n<N;c=N%++n||n,d=c+N-n,k+=d*-~d*(d-~d)-~-c*c*(c+c-1));k/6') [Try it online!][TIO-kzwxqvxg] [JavaScript (Node.js)]: https://nodejs.org [TIO-kzwxqvxg]: https://tio.run/##FYxLDoIwFACv8jaGfl4V/KAG6xF6AeOCtNQo@GoAWRGuXutmVjPzqqd6sP3zMyoKroleR6OvzVR3LPOhZ60mnVd0MZXVZiUlzTOh01YaRdhK7YRanGAukatFWWEFs9KqgvOq3ZQZj@kCzAYaRqDvG4KHW4GwRdgh7BEOCCXCEeGEcEYo8juHvx26Zt2FB/MsVWkWfw "JavaScript (Node.js) – Try It Online" *-1 by @KevinCruijssen* Directly calculates the sum for each `n`, rather than iteratively doing so.