Skip to main content
4 of 4
deleted 1 character in body
randomra
  • 20.9k
  • 4
  • 46
  • 111

J, 23 22 chars

   (+/ .*&2 3 4 1@(+<./))

Example:

   test =. 3 5 4 3
   (+/ .*&2 3 4 1@(+<./)) test
70

Try it here.

(23 long explicit function definition: v=:3 :'+/+/\.3|.y+<./y')

randomra
  • 20.9k
  • 4
  • 46
  • 111