Skip to content

Function: arithmeticSequence()

ts
function arithmeticSequence(
   firstTerm, 
   commonDifference, 
   numberOfTerms): number[];

Generates an arithmetic sequence. 生成等差数列。

Parameters

ParameterTypeDescription
firstTermnumberThe first term / 首项
commonDifferencenumberThe common difference / 公差
numberOfTermsnumberThe number of terms / 项数

Returns

number[]

An array containing the arithmetic sequence / 包含等差数列的数组

Example

typescript
arithmeticSequence(2, 3, 5) // => [2, 5, 8, 11, 14]
arithmeticSequence(10, -2, 6) // => [10, 8, 6, 4, 2, 0]

Since

1.0.0

Released under the MIT License.