freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/averages-pythagorean-means.md

1.9 KiB
Raw Blame History

id title challengeType videoUrl
594d966a1467eb84194f0086 平均值 - 毕达哥拉斯指的是 5

--description--

计算整数1到10 (包括)的所有三个毕达哥拉斯方法

为这组正整数显示$ Ax_1\ ldotsx_n\ geq Gx_1\ ldotsx_n\ geq Hx_1\ ldotsx_n$ 。

这三种方法中最常见的算术平均值是列表的总和除以其长度: $ Ax_1\\ ldotsx_n= \\ frac {x_1 + \\ cdots + x_n} {n} $ 几何mean是列表产品的$ n $ th根 $ Gx_1\\ ldotsx_n= \\ sqrt \[n] {x_1 \\ cdots x_n} $ 调和平均值是$ n $除以总和列表中每个项目的倒数: $ Hx_1\\ ldotsx_n= \\ frac {n} {\\ frac {1} {x_1} + \\ cdots + \\ frac {1} {x_n}} $

假设输入是包含所有数字的有序数组。

要获得答案,请按以下格式输出对象:

 {
  值:{
    算术5.5
    几何4.528728688116765
    谐波3.414171521474055
  }
  测试:'是A> = G> = H是'
}

--hints--

pythagoreanMeans是一种功能。

assert(typeof pythagoreanMeans === 'function');

pythagoreanMeans([1, 2, ..., 10])应该等于上面相同的输出。

assert.deepEqual(pythagoreanMeans(range1), answer1);

--solutions--