Python | 程序来计算斐波那契数列的第n个项

Python program to calculate n-th term of Fibonacci series with the help to two approaches (there are many approaches to calculate n-th term).

Python程序借助两种方法来计算斐波那契数列的第n个项 (有许多方法可以计算第n个项)。

Description:

描述:

  1. First Approach: Dynamic Programming

    第一种方法:动态编程

    In this approach, we calculate all the terms of Fibonacci series up to n and if we need to calculate any other term which is smaller than n, then we don’t have to calculate it again.

    在这种方法中,我们计算出斐波那契数列直到n的所有项,如果我们需要计算小于n的任何其他项,则不必再次计算。

  2. Second Approach: By Formula

    第二种方法:按公式

    In this approach we calculate the n-th term of Fibonacci series with the help of a formula.

    在这种方法中,我们借助公式计算斐波纳契数列的第n个项。

你可能感兴趣的:(python,算法,人工智能,编程语言,机器学习)