javascript · BEGINNER · Public challenge

Prefix Sums

Challenge

Print the running totals of the array: the i-th output is the sum of the first i elements.

Example
Input:
5
1 2 3 4 5
Output: 1 3 6 10 15

Input: Line 1: n. Line 2: n integers.
Output: n running totals on one line.
Constraints: 1 <= n <= 1000

  • Arrays
  • JavaScript

Browse all challenges