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

2.6 KiB
Raw Blame History

title id challengeType videoUrl localeTitle
Averages-Pythagorean means 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是'
}

Instructions

Tests

tests:
  - text: <code>pythagoreanMeans</code>是一种功能。
    testString: 'assert(typeof pythagoreanMeans === "function", "<code>pythagoreanMeans</code> is a function.");'
  - text: '<code>pythagoreanMeans([1, 2, ..., 10])</code>应该等于上面相同的输出。'
    testString: 'assert.deepEqual(pythagoreanMeans(range1), answer1, "<code>pythagoreanMeans([1, 2, ..., 10])</code> should equal the same output above.");'

Challenge Seed

function pythagoreanMeans (rangeArr) {
  // Good luck!
}

After Test

console.info('after the test');

Solution

// solution required