Skip to content

Function: geometricSequence()

ts
function geometricSequence(
   firstTerm, 
   commonRatio, 
   numberOfTerms): number[];

Generates a geometric sequence. 生成等比数列。

Parameters

ParameterTypeDescription
firstTermnumberThe first term / 首项
commonRationumberThe common ratio / 公比
numberOfTermsnumberThe number of terms / 项数

Returns

number[]

An array containing the geometric sequence / 包含等比数列的数组

Example

typescript
geometricSequence(2, 3, 5) // => [2, 6, 18, 54, 162]
geometricSequence(1, 0.5, 4) // => [1, 0.5, 0.25, 0.125]

Since

1.0.0

Released under the MIT License.