递归算法中的递归公式_算术序列的递归公式

2021年6月30日 4点热度 0条评论 来源: cumian9828

递归算法中的递归公式

什么是算术序列? (What is an Arithmetic Sequence?)

A sequence is list of numbers where the same operation(s) is done to one number in order to get the next. Arithmetic sequences specifically refer to sequences constructed by adding or subtracting a value – called the common difference to get the next term.

序列是数字列表,其中对一个数字执行相同的操作以获得下一个数字。 算术序列特别是指通过加或减一个值(称为共同差 )而获得下一项所构造的序列。

In order to efficiently talk about a sequence, we use a formula that builds the sequence when a list of indices are put in. Typically, these formulas are given one-letter names, followed by a parameter in parentheses, and the expression that builds the sequence on the right hand side.

为了有效地讨论序列,我们使用了一个公式,该公式将在放置索引列表时构建该序列。通常,这些公式被赋予一个字母的名称,后跟括号中的参数,以及用于构建序列的表达式。序列在右侧。

a(n) = n + 1

a(n) = n + 1

Above is an example of a formula for an arithmetic sequence.

上面是算术序列公式的示例。

例子 (Examples)

Sequence: 1, 2, 3, 4, … | Formula: a(n) = n + 13

顺序:1、2、3、4…| 公式:a(n)= n + 13

Sequence: 8, 13, 18, … | Formula: b(n) = 5n - 2

顺序:8、13、18,…| 公式:b(n)= 5n-2

递归公式 (A Recursive Formula)

Note: Mathematicians start counting at 1, so by convention, n=1 is the first term. So we must define what the first term is. Then we have to figure out and include the common difference.

注意:数学家从1开始计数,因此按照惯例, n=1是第一项。 因此,我们必须定义第一个术语是什么。 然后我们必须找出并包括共同点。

Taking a look at the examples again,

再看看这些例子,

Sequence: 1, 2, 3, 4, … | Formula: a(n) = n + 1 | Recursive formula: a(n) = a(n-1) + 1, a(1) = 1

顺序:1、2、3、4…| 公式:a(n)= n +1 | 递归公式:a(n)= a(n-1)+ 1,a(1)= 1

Sequence: 3, 8, 13, 18, … |Formula: b(n) = 5n - 2 | Recursive formula: b(n) = b(n-1) + 5, b(1) = 3

序列:3、8、13、18,... |公式:b(n)= 5n-2 | 递归公式:b(n)= b(n-1)+ 5,b(1)= 3

查找公式(给以第一项的序列) (Finding the Formula (given a sequence with the first term))

1. Figure out the common difference
    Pick a term in the sequence and subtract the term that comes before it.         
2. Construct the formula
    The formula has the form: `a(n) = a(n-1) + [common difference], a(1) = [first term]`

查找公式(给出没有第一项的序列) (Finding the Formula (given a sequence without the first term))

1. Figure out the common difference
    Pick a term in the sequence and subtract the term that comes before it. 
2. Find the first term
    i. Pick a term in the sequence, call it `k` and call its index `h`
    ii. first term = k - (h-1)*(common difference)
3. Construct the formula
    The formula has the form: `a(n) = a(n-1) + [common difference], a(1) = [first term]`

更多信息: (More Information:)

For more information on this topic, visit

有关此主题的更多信息,请访问

翻译自: https://www.freecodecamp.org/news/recursive-formulas-for-arithmetic-sequences/

递归算法中的递归公式

    原文作者:cumian9828
    原文地址: https://blog.csdn.net/cumian9828/article/details/108153238
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。