g | x | w | all
Bytes Lang Time Link
021AWK171017T144153ZNahuel F
016Raku230612T150957ZSean
003Nekomata230612T035650Zalephalp
019Arturo230610T203106Zchunes
002Thunno 2 S230610T165318ZThe Thon
003Pyt221217T152309ZKip the
003Vyxal221011T071814ZDialFros
003MATL171017T115552ZLuis Men
030Flurry200814T010153ZBubbler
003Jelly181019T221234ZMr. Xcod
010Milky Way171025T125711Zovs
022Python 2171017T115409ZMr. Xcod
033 Python171101T110127ZpCozmic
013Add++171025T211322Zcaird co
019Funky171019T051749ZATaco
028Befunge171019T195728ZBrian Gr
010TIBasic171019T151412ZTimtech
009J171018T041219ZConor O&
005Pyth171017T152655ZDave
011><>171017T141819ZEmigna
018JavaScript ES6171018T133021ZShaggy
023Hexagony171018T090029ZMartin E
003Japt171017T121353ZErik the
019Excel171018T111504ZWernisch
021Perl 5171017T142413ZNahuel F
012dc171018T102055ZToby Spe
030Common Lisp171018T043603ZRenzo
034BrainFlak171017T185929ZWheat Wi
036MaybeLater171018T002650ZATaco
010TIBASIC171018T000255ZKhuldrae
053ReRegex171017T235611ZATaco
040Threead171017T231705ZATaco
010TacO171017T223730ZATaco
149Postscript171017T222753ZMongoThe
016R171017T202718ZLeaky Nu
013ARBLE171017T132158ZATaco
020C#.NET Core171017T182326ZProbably
020Haskell171017T162927Znimi
009K oK171017T162630Zmkst
016Befunge171017T124437ZCinaski
015Cubix171017T141501ZGiuseppe
030Bash171017T151214Z0x45
020Jq 1.5171017T153815Zjq170727
006Pushy171017T153633ZLuis Men
010Pyth171017T151752ZIan H.
012Alice171017T132553ZMartin E
011Labyrinth171017T150509ZMartin E
014Julia171017T120814ZUriel
008Recursiva171017T141808Z0xffcour
003cQuents 0171017T134840ZStephen
016Pari/GP171017T134221Zalephalp
020Retina171017T133236ZMartin E
018Ruby171017T133218ZG B
036BrainFlak171017T132107ZRiley
009CJam171017T132832ZMartin E
016JavaScript ES6171017T120722ZArnauld
017R171017T131452ZRudier
036Tcl171017T130357Zsergiol
021Haskell171017T125612Zuser4594
005APL Dyalog171017T120330ZUriel
003Ohm v2171017T120055ZCinaski
014Octave171017T122943Zrahnema1
016Java 8171017T121835ZRoberto
003Actually171017T123149Zuser4594
0394171017T122328ZUriel
004Pyke171017T122015ZMr. Xcod
003Gaia171017T121714ZMr. Xcod
005Brachylog171017T121316ZFatalize
014Wolfram Language Mathematica171017T120128Ztotallyh
004Oasis171017T120413ZEmigna
016Proton171017T115918Zhyperneu
003Neim171017T120957ZOkx
00305AB1E171017T120319ZEmigna
010CJam171017T120542ZLuis Men
003Husk171017T120519ZMr. Xcod
013QBIC171017T120412Zsteenber
046BrainFlak171017T120226Zhyperneu
003Jelly171017T115551Zhyperneu

AWK, 25 21 bytes

Thansk to xrs

$0=$1^3/3+$1^2/2+$1/6

Try it online!

Raku, 16 bytes

[\+] {$++²}...*

Try it online!

This is an expression for the lazy infinite sequence of numbers.

Nekomata, 3 bytes

R:∙

Attempt This Online!

R:∙
R     Range
 :    Duplicate
  ∙   Dot product

Because there isn't a square built-in yet.

Arturo, 19 bytes

$=>[∑map&=>[&^2]]

Try it!

Thunno 2 S, 2 bytes

Attempt This Online!

Explanation

R²  # Implicit input
R   # Range of input
 ²  # Square each
    # Sum the list
    # Implicit output

Pyt, 3 bytes

ř²Ʃ

Try it online!

ř²Ʃ
       implicit input
ř      creates array of 1 to n
 ²     squares each element
  Ʃ    sums the list
       implicit print

Vyxal, 3 bytes

ɾ²∑

Try it Online!

Explained

ɾ²∑
ɾ   # range 1 inclusive [1...n]
 ²  # square
  ∑ # sum

MATL, 3 bytes

:Us

... or them?

Try it online!

Explanation

:Us
:    % Implicit input n. Push range [1 2 ... n]
 U   % Square, element-wise
  s  % Sum of array. Implicit display

Flurry, 30 bytes

{}{({})[<><<>()>]<[][]>}[<>()]

Run example

$ ./flurry -nin -c "{}{({})[<><<>()>]<[][]>}[<>()]" 0
0
$ ./flurry -nin -c "{}{({})[<><<>()>]<[][]>}[<>()]" 1
1
$ ./flurry -nin -c "{}{({})[<><<>()>]<[][]>}[<>()]" 3
14
$ ./flurry -nin -c "{}{({})[<><<>()>]<[][]>}[<>()]" 6
91

The computation is done via the stack, but the final result is outputted from the return value.

Given that we can keep track of iteration indexes using the stack height and multiplication is cheap in Flurry, there's really no "clever" alternative that can lead to shorter code.

{}{...}[<>()]  Repeat the lambda n times with the start value of zero
                 (implicit) push argument x to the stack
  ({})           Pop and re-push x; return x
  [<><<>()>]     succ
  <[][]>         (height ∘ height)
                 In effect, push x and return x + height^2

Jelly, 3 bytes

Rḋ`

Try it online!

Milky Way, 10 bytes

'L§{:*}G!

Try it online!

Explanation:

'          push input to stack
 L         push inclusive range
  ${  }    map over every element ...
    :*     ... duplicate and multiply (square it)
       G   sum of list
        !  output

Python 2, 22 bytes

lambda n:n*~n*~(n*2)/6

Try it online!

This uses the closed-form formula n * (n+1) * (2*n+1) / 6. The code performs the following operations:

Python 2, 27 bytes

f=lambda n:n and f(n-1)+n*n

Try it online!

Saved 1 byte thanks to Rod and 1 thanks to G B.

Python, 38 33 bytes

-5 bytes thanks to Martin Ender

g=lambda x:x*x+g(x-1) if x else 0


Haven't seen any solution with recursion yet, so I thought I'd post this one. It may not be really competitive, but this is my first time posting.

Edit: It would've been -11 bytes thanks to Martin Ender, but I would've ended up with the same answer as Mr. Xcoder's

Add++, 13 bytes

D,f,@,RdBcB*s

Try it online!

D,f,@,   - Create a monadic function called f. Argument n (example: 5)
      R  - Generate range;   STACK = [[1 2 3 4 5]]
      d  - Duplicate;        STACK = [[1 2 3 4 5] [1 2 3 4 5]]
      Bc - Push the columns; STACK = [[1 1] [2 2] [3 3] [4 4] [5 5]]
      B* - Product of each;  STACK = [1 4 9 16 25]
      s  - Push the sum;     STACK = [1 4 9 16 25 55]
         - Implicitly return 55

Funky, 33 24 19 bytes

-9 bytes thanks to Dennis

-5 bytes thanks to ASCII-only and bugfixes.

f=n=>n?f(n-1)+n*n:0

Try it online!

Befunge, 28 bytes

&00pg#v_.@
-1:g00<^g00+*:p00

Works for inputs in the range [0, 128). Due to befunge being entirely stack-based, and yet having limited stack manipulation operations available, the only way to work with three values (sum, partial sum, and counter) is to store a value temporarily by modifying the program itself using the p instruction. Since p assigns a value as ASCII, the stored value wraps around at 128, storing a negative value instead of a positive value.

Try it online!

Befunge, 30 bytes

& >::*\:v
$<^-1_v#<@.
_^#:\+<\

Works for pretty much any input.

Try it online!

TI-Basic, 10 bytes

sum(seq(OO,O,0,Ans

sp00ky

J, 10 9 bytes

4%~3!2*>:

Try it online!

Saved 1 byte using an explicit formula, thanks to miles!


J, 10 bytes

1#.]*:@-i.

J has a range function, but this gives us number from 0 to N-1. To remedy this, we can just take the argument and subtract the range from it, giving us a range from N to 1. This is done with ] -i.. The rest of the code simply square this list argument (*:@) and then sums it (1#.).

Other contenders

11 bytes: 1#.*:@i.@>:

13 bytes: 1#.[:,@:*/~i.

Pyth, 7 5 bytes thanks to Steven H

s^R2h

Explanation:

s^R2h       Full program - inputs from stdin and outputs to stdout
s           output the sum of
    h       range(input), with
 ^R2         each element squared

My first solution

sm*ddUh

Try it online!

Explanation:

sm*ddUh    Full program - inputs from stdin and outputs to stdout
s          sum of
 m   Uh    each d in range(input)
  *dd      squared

><>, 15 13 11 bytes

Saved 2 bytes thanks to Not a tree

0:n:l1-:*+!

Try it online!

Outputs the sequence indefinitely.

JavaScript (ES6), 18 bytes

f=n=>n&&n*n--+f(n)

Try it

o.innerText=(
f=n=>n&&n*n--+f(n)
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number><pre id=o>

Hexagony, 23 bytes

?'+)=:!@/*"*'6/{=+'+}/{

Try it online!

Explanation

Unfolded:

   ? ' + )
  = : ! @ /
 * " * ' 6 /
{ = + ' + } /
 { . . . . .
  . . . . .
   . . . .

This is really just a linear program with the / used for some redirection. The linear code is:

?'+){=+'+}*"*'6{=:!@

Which computes n (n+1) (2n+1) / 6. It uses the following memory edges:

enter image description here

Where the memory point (MP) starts on the edge labelled n, pointing north.

?   Read input into edge labelled 'n'.
'   Move MP backwards onto edge labelled 'n+1'.
+   Copy 'n' into 'n+1'.
)   Increment the value (so that it actually stores the value n+1).
{=  Move MP forwards onto edge labelled 'temp' and turn around to face
    edges 'n' and 'n+1'.
+   Add 'n' and 'n+1' into edge 'temp', so that it stores the value 2n+1.
'   Move MP backwards onto edge labelled '2n+1'.
+   Copy the value 2n+1 into this edge.
}   Move MP forwards onto 'temp' again.
*   Multiply 'n' and 'n+1' into edge 'temp', so that it stores the value
    n(n+1).
"   Move MP backwards onto edge labelled 'product'.
*   Multiply 'temp' and '2n+1' into edge 'product', so that it stores the
    value n(n+1)(2n+1).
'   Move MP backwards onto edge labelled '6'.
6   Store an actual 6 there.
{=  Move MP forwards onto edge labelled 'result' and turn around, so that
    the MP faces edges 'product' and '6'.
:   Divide 'product' by '6' into 'result', so that it stores the value
    n(n+1)(2n+1)/6, i.e. the actual result.
!   Print the result.
@   Terminate the program.

In theory it might be possible to fit this program into side-length 3, because the / aren't needed for the computation, the : can be reused to terminate the program, and some of the '"=+*{ might be reusable as well, bringing the number of required commands below 19 (the maximum for side-length 3). I doubt it's possible to find such a solution by hand though, if one exists at all.

Japt, 3 bytes

ô²x

Try it here.

-1 thanks to Shaggy.

Explanation:

ò²x 
ô²  Map square on [0..input]
  x Sum

Excel, 19 bytes

=A1^3/3+A1^2/2+A1/6

Perl 5, 24, 21 bytes

Thanks to Dom, solutions with 21 bytes

$\+=$_--**2while$_}{

or

map$\+=$_**2,1..$_}{

or

$\+=$_**2for 1..$_}{

previous were 21 + 1 -p flag, 3 bytes saved thanks to Xcali

$_*=($_+1)*(2*$_+1)/6

and 23 +1

$_=$_*($_+1)*(2*$_+1)/6

or

$_=$_**3/3+$_**2/2+$_/6

dc, 15 12 bytes

d1+dd+1-**6/

This is simply the factorised Faulhaber polynomial: n(n+1)(2n+1)/6, except that the (2n+1) term is calculated as 2(n+1)-1.

Common Lisp, 30 bytes

(loop as i to(read)sum(* i i))

Try it online!

Brain-Flak, 34 bytes

({(({}[()])()){({}[()])({})}{}}{})

Try it online!

How does it work?

Initially I had the same idea as Riley1 but it felt wrong to use a zeroer. I then realized that

{({}[()])({})}{}

Calculates n2 - n.

Why? Well we know

{({})({}[()])}{}

Calculates n2 and loops n times. That means if we switch the order of the two pushes we go from increasing the sum by n + (n-1) each time to increasing the sum by (n-1) + (n-1) each time. This will decrease the result by one per loop, thus making our result n2 - n. At the top level this -n cancels with the n generated by the push that we were zeroing alleviating the need for a zeroer and saving us two bytes.

Brain-Flak, 36 bytes

({({})(({}[()])){({})({}[()])}{}}{})

Try it online!

Here is another solution, its not as golfy but it's pretty strange so I thought I would leave it as a challenge to figure out how it works.

If you are not into Brain-Flak but you still want the challenge here it is as a summation.

Picture


1: I came up with my solution before I looked at the answers here. So no plagiarism here.

MaybeLater, 36 bytes

n=(readn)/1
write(n*(n+1)*(1+n*2)/6)

Using the closed form formula.

Try it online!

TI-BASIC, 10 bytes

sum(seq(X²,X,0,Ans

Quite simple. The sum of the sequence of the first Ans squares.

ReRegex, 53 bytes

#import math
^k([1-9]\d*)/k($1-1)+$1*$1/k0+/0/k#input

Explained

#import math                # Import the math library.
^k([1-9]\d*)/k($1-1)+$1*$1/ # Search the buffer for "k" followed by a non-zero number. Replace it with "k<n-1>+n*n"
k0+/0/                      # Replace k0 with just 0
k#input                     # Default the buffer to k<input>

Try it online!

Threead, 40 bytes

I[     -]_
   _^>1
  _2 _r

[<

 lo
 ]
+

Try it online!

De-sliced

This is actually 4 bytes larger, due to whitespace.

I[     -]_   lo
   _^>1   [< ]
  _2 _r     +

Process.

  1. Read an integer into the first value
  2. While the first value is non-zero.
    1. Blank the third value, push 2 onto it.
    2. Blank the second value, then calculate the first value to the power of the third, (i^2)
    3. Move the second value to the right and place a 1 onto it.
    4. Put the value of the first value onto the third value.
    5. Calculate the third value minus the second value (i-1)
  3. Now the second tape contains the squares of all numbers from inp to 1 squared.
  4. Blank the first value
  5. While the second value is non-zero
    1. Move the second tape to the left.
    2. Add the first value to the second value into the third value.
    3. Move the third value into the first value
  6. Now, all the i^2 values are summed together, output the first value.

TacO, 10 bytes

@i i
+%+*i

Try it online!

Postscript, 149 bytes

/d {def}def
/a {
0 i l 1 0 l
i 2 ge {/i i 1 sub d a}if
} d
/l {rlineto}d
/m {moveto}d
/b {/j exch d /i j d 0 0 m j a j 0 lineto closepath fill}d
5 b

R, 16 bytes

(n=0:scan())%*%n

Try it online!

ARBLE, 14 13 bytes

-1 bytes thanks to Mr. Xcoder

n*~n*~(n+n)/6

Try it online!

C#(.NET Core), 20 bytes

a=>a*(a+1)*(2*a+1)/6

Try it online!

Haskell, 20 bytes

f 0=0
f n=n*n+f(n-1)

Try it online!

K (oK), 9 bytes

Solution:

+/x*x:!1+

Try it online!

Examples:

> +/x*x:!1+4
30
> +/x*x:!1+5
55

Explanation:

Evaluated right-to-left:

+/x*x:!1+ / solution
       1+ / add 1 to input, 1+4 => 5
      !   / til, !5 => 0 1 2 3 4
    x:    / save as variable x
  x*      / vectorised multiplication, x*x, 0 1 2 3 4*0 1 2 3 4 => 0 1 3 9 16
+/        / addition over (sum), +/0 1 3 9 16 => 30

Befunge, 16 bytes

&::2*1+*\1+*6/.@

Using the closed-form formula n*(n+1)*(2n+1)/6.

Try it online!

Befunge, 38 bytes

v>::*\1-:v0+_$.@
&^ <     _\:^
>:#^_.@

Using a loop.

Try it online!

Cubix, 15 bytes

Iu):^\+*p*6u@O,

Try it online!

My code is a bit sad ):

Computes n*(n+1)*(2n+1)/6

    I u
    ) :
^ \ + * p * 6 u
@ O , . . . . .
    . .
    . .

^Iu : read in input, u-turn
    : stack  n
:)\ : dup, increment, go right..oh, hey, it cheered up!
    : stack: n, n+1
+   : sum
    : stack: n, n+1, 2*n+1
*   : multiply
    : stack: n, n+1, 2*n+1, (n+1)*(2*n+1)
p   : move bottom of stack to top
    : stack: n+1, 2*n+1, (n+1)*(2*n+1), n
*   : multiply
6   : push 6
u   : right u-turn
,   : divide
O   : output
@   : terminate

Bash, 48 30 bytes

echo "$1*($1+1)*(2*$1+1)/6"|bc

Try it online!

Jq 1.5, 20 bytes

[range(.+1)|.*.]|add

Input is N. Output is N'th element of sequence. Expanded:

[
    range(.+1)            # generate series 0, 1, 2, 3, ... N
  | .*.                   # square each term
]                         # collect into an array
| add                     # compute the sum

Try it online!

Pushy, 6 bytes

R2KeS#

Try it online!

Explanation

R     Push integers from 1 to implicit n, where n is implicit input
2     Push 2
K     Next command will use the entire stack
e     Pop 2. Raise each of the remaing stack entries to that
S     Sum the entire stack
#     Print as integer

Pyth, 10 bytes

VhQ=+Z^N2Z

Outputs the first N elements of the sequence.

Try it online!


How?

VhQ=+Z^N2Z              Full program

VhQ                     Loop until Q + 1 is reached
   =+Z                  Assign and increment Z by ...
      ^N2               ... N squared
         Z              Implicity prints Z

11 byte alternative.

VhQ aY^N2sY

Try it online!

Alice, 17 12 bytes

./ O \d2E+.

Try it online!

Prints the sequence indefinitely.

The trailing linefeed is significant.

Explanation

.   Duplicate the current total. Initially this pushes two zeros onto the
    previously empty stack.
/   Switch to Ordinal.
O   Print the current total with a trailing linefeed.
\   Switch back to Cardinal.
d   Push the stack depth, which acts as a counter variable.
2E  Square it.
+   Add it to the current total.
.   Duplicate it to increment the stack depth for the next iteration.

Labyrinth, 11 bytes

:!\
+ :
*:#

Try it online!

Prints the sequence indefinitely.

Explanation

The instruction pointer just keeps running around the square of code over and over:

:!\    Duplicate the last result (initially zero), print it and a linefeed.
:      Duplicate the result again, which increases the stack depth.
#      Push the stack depth (used as a counter variable).
:*     Square it.
+      Add it to the running total.

Julia, 16 14 bytes

2 bytes saved thanks to @MartinEnder

!n=(x=1:n)⋅x

Try it online!

How?

(x=1:n) creates a range of 1 to n and assign to x, dot product with x.

Recursiva, 8 bytes

smBa'Sa'

Try it online!

cQuents 0, 3 bytes

;$$

Try it online!

Take that, Oasis.

Explanation

;     Mode: Sum - given n, output the sum of the sequence up to n
 $$   Each term in the sequence equals the index * the index

Pari/GP, 16 bytes

n->(v=[0..n])*v~

Try it online!

Retina, 20 bytes

.+
$*
M!&`.+
1
$%_
1

Try it online!

Explanation

.+
$*

Convert input to unary.

M!&`.+

Get all overlapping matches of .+ which turns the input into a range of unary numbers from 1 to n.

1
$%_

Replace each 1 with the entire line its on, squaring the unary value on each line.

1

Count the number of 1s, summing all lines and converting them back to decimal.

Ruby, 18 bytes

->n{n*~n*~(n+n)/6}

Using the sama formula as everybody else, saved 1 byte with a double negative multiplication.

Try it online!

Brain-Flak, 36 bytes

({<(({}[()])())>{({})({}[()])}{}}{})

Try it online!

# Main algorithm
(                                  )  # Push the sum of:
                {({})({}[()])}{}      #   The square of:
 {                              }     #     0 to i 

# Stuff for the loop
  <(({}[()])())>                      # Push i-1, i without counting it in the sum
                                 {}   # Pop the counter (0)

CJam, 9 bytes

ri),_.*:+

Try it online!

Explanation

ri        e# Read input and convert to integer N.
  ),      e# Get range [0 1 2 ... N].
    _     e# Duplicate.
     .*   e# Pairwise products, giving [0 1 4 ... N^2].
       :+ e# Sum.

Alternatively:

ri),2f#:+

This squares each element by mapping 2# instead of using pairwise products. And just for fun another alternative which gets inaccurate for large inputs because it uses floating-point arithmetic:

ri),:mh2#

JavaScript (ES6), 16 bytes

n=>n*(n+++n)*n/6

Demo

let f =

n=>n*(n+++n)*n/6

for(n = 0; n < 10; n++) {
  console.log('a(' + n + ') = ' + f(n))
}

How?

The expression n+++n is parsed as n++ + n (1). Not that it really matters because n + ++n would also work in this case.

Therefore:

n*(n+++n)*n/6 =
n * (n + (n + 1)) * (n + 1) / 6 =
n * (2 * n + 1) * (n + 1) / 6

which evaluates to sum(k=0...n)(k²).


(1) This can be verified by doing n='2';console.log(n+++n) which gives the integer 5, whereas n + ++n would give the string '23'.

R, 17 bytes

sum((0:scan())^2)

Pretty straightforward, it takes advantage from the fact that ^ (exponentiation) is vectorized in R.

Tcl, 36 bytes

proc S n {expr $n*($n+1)*(2*$n+1)/6}

Try it online!

Haskell, 21 bytes

f n=n*(n+1)*(2*n+1)/6

Try it online!

Boring, straightforward implementation of the closed-form formula on the OEIS page. Expanding into polynomial form doesn't save any bytes: f n=(2*n^3+3*n^2+n)/6.

APL (Dyalog), 7 5 bytes

2 bytes saved thanks to @Mego

+.×⍨⍳

Try it online!

How?

- range

+.× - dot product

- with itself

Ohm v2, 3 bytes

#²Σ

Try it online!

Explanation

#    Range
 ²   Square
  Σ  Sum

Octave, 14 bytes

@(k)(a=0:k)*a'

Try it online!

*Dot product.

Or

@(k)sumsq(0:k)

Try it online!

Java 8, 78 57 35 16 bytes

@Arnauld port

i->i*(i+++i)*i/6

Actually, 3 bytes

R;*

Try it online!

Takes N as input, and outputs the Nth element in the sequence.

Explanation:

R;*
R    range(1, N+1) ([1, 2, ..., N])
 ;*  dot product with self

4, 39 bytes

3.7006110180020100000030301100001195034

Try it online!

How?

3.
7 00        grid[0] = input()
6 11 01     grid[11] = 1
8 00        while grid[0] != 0:
2 01 00 00     grid[1] = grid[0] * grid[0]
0 03 03 01     grid[3] = grid[3] + grid[1]
1 00 00 11     grid[0] = grid[0] - grid[11]
9         
5 03        print(grid[3]) 
4

Pyke, 4 bytes

hLXs

Try it here!

or...

SMXs

Gaia, 3 bytes

s¦Σ

Try it online!

Brachylog, 5 bytes

⟦^₂ᵐ+

Try it online!

Explanation

⟦        Range
 ^₂ᵐ     Map square
    +    Sum

Wolfram Language (Mathematica), 14 bytes

Tr[Range@#^2]&

Try it online!

Oasis, 4 bytes

nk+0

Try it online!

Explanation

   0      # a(0) = 0
nk+       # a(n) = a(n-1)+n^2

Proton, 16 bytes

x=>x*(x+++x)*x/6

Try it online!

Straightforward Solution: range+map(x=>x**2)+sum

-2 bytes thanks to Arnauld('s answer)

Neim, 3 bytes

𝐈ᛦ𝐬

This could've been a challenge to show off Neim's polygonal number builtins, but apparently not.

Try it online!

05AB1E, 3 bytes

ÝnO

Try it online!

Explanation

  O    # sum of
 n     # squares of
Ý      # range [0 ... input]

CJam, 10 bytes

ri),{_*+}*

Try it online!

ri            e# Input integer n
  )           e# Add 1
   ,          e# Range [0 1 ... n]
    {   }*    e# Fold (reduce)
     _        e# Duplicate
      *       e# Multiply
       +      e# Add

Husk, 3 bytes

ṁ□ḣ

Try it online!

QBIC, 13 bytes

[:|p=p+a^2]?p

Explanation

[:|    FOR a = 1 to <input from cmd line>
p=p+   increment p by
a^2    a squared
]      NEXT
?p     PRINT p

Brain-Flak, 46 bytes

{(({})[()])}{}{({({})({}[()])}{}<>)<>}<>({{}})

Try it online!

Jelly, 3 bytes

R²S

Try it online!

FGITW

Explanation

R²S  Main Link
R    Generate Range
 ²   Square (each term)
  S  Sum