Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.

Use Array.prototype.reduce() to calculate how many numbers are below the value and how many are the same value and apply the percentile formula.

继续阅读 30秒学会 JavaScript 片段 – percentile

Returns the least common multiple of two or more numbers.

Define a gcd() function that determines the greatest common divisor, using recursion.
Use gcd() and the fact that LCM(x, y) = x * y / GCD(x,y) to determine the least common multiple.
Use range to apply the calculation to all given numbers.

继续阅读 30秒学会 Golang 片段 – LCM

Returns the standard deviation of an array of numbers.

Use Array.prototype.reduce() to calculate the mean, variance and the sum of the variance of the values, the variance of the values, then
determine the standard deviation.
You can omit the second argument to get the sample standard deviation or set it to true to get the population standard deviation.

继续阅读 30秒学会 JavaScript 片段 – standardDeviation