Algorithm name and input parameters: computeSum(numbers)

computeSum(numbers)
Problem Statement:
Write an algorithm named "computeSum" to compute the sum of a collection of numbers. Return the result.

Given: Variable 'numbers' that holds a collection of numbers.
Sample 1:


Sample 2:
Writing Algorithm in Human Language
Write the algorithm in pseudocode.


Human Language:
computeSum(elements) {
	Let i be set to 0
	Let len equal to length of elements
	Let sum be set to zero
	While i is less than len
		Let nextElement equal to the element in elements at index i
		Let sum equal sum plus nextElem
		Let i bet set to i plus 1
Return sum
}
Writing Algorithm in Pseudocode
Write the algorithm in pseudocode.


Pseudocode:
function computeSum(elements) {
	let i = 0
	let len = elements.length
	let sum = 0
	while (i < len) {
		let nextElem = elements[i]
		sum += nextElem
		i += 1
	}
	return sum
}

_hiddenSource_

//Try It
let nums = [10, 20, 30, 40]
let sum = computeSum(nums);

println("Sum: " + sum);