Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-321

Geometric Mean of Growth Factors

Problem

For a sequence of growth factors g_i (for example 1.1 for ten percent growth), the compound average factor is the geometric mean (product_i g_i)^(1/n).

Given the growth factors, return the geometric mean.

Hint

Multiply all factors together and take the n-th root.

Test cases

case 1
in: [[1.1,1.2]]
expected: 1.1489125293076057
case 2
in: [[1,1,1]]
expected: 1
case 3
in: [[2,8]]
expected: 4
Starter codePython
def geometric_mean_of_growth_factors(factors):
    # Your code here
    pass

3 test cases · run your code against them in the editor