3 of 3 added 42 characters in body

APL (Dyalog), 7 5 bytes

2 bytes saved thanks to @Mego

+.×⍨⍳

Try it online!

How?

- range

+.× - dot product

- with itself