Skip to main content
2 of 2
Commonmark migration

APL+WIN, 18 bytes

Prompts for vector of integers:

+/(2,⌈.5×⍴s)⍴s←0,⎕

Try it online! Coutesy of Dyalog Classic

Graham
  • 6.8k
  • 1
  • 15
  • 11