APL (Dyalog), 7 5 bytes
2 bytes saved thanks to @Mego
+.×⍨⍳
How?
⍳
- range
+.×
- inner product (a +.× b
→ +/ a × b
)
⍨
- with itself (on both sides)
2 of 3 | added 42 characters in body | ||||
APL (Dyalog),
|