Function: arithmeticSequence()
ts
function arithmeticSequence(
firstTerm,
commonDifference,
numberOfTerms): number[];Generates an arithmetic sequence. 生成等差数列。
Parameters
| Parameter | Type | Description |
|---|---|---|
firstTerm | number | The first term / 首项 |
commonDifference | number | The common difference / 公差 |
numberOfTerms | number | The 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