Average of a Fixed-Size Array
Problem statement
Given a non-empty fixed-size array of integers numbers, return its arithmetic mean.
The arithmetic mean is the sum of all values divided by the number of values.
Function
calculateAverage(numbers: int[]) → doubleExamples
Example 1
numbers = [1,2,3,4]return = 2.5The sum is 10, and 10 / 4 = 2.5.
Example 2
numbers = [7]return = 7.0A single-element array has that element as its mean.
Example 3
numbers = [-5,0,5,10]return = 2.5The values sum to 10, so the mean is 10 / 4 = 2.5.
Constraints
1 <= numbers.length <= 10^5.-10^9 <= numbers[i] <= 10^9.- The sum of all values fits in a signed 64-bit integer.