Рубрики
Без рубрики

Функция последовательности Фибоначчи

# fibonacci_sectence.py # Эта программа вычисляет номер Nth Fibonacci, где n – значение … Tagged с помощью Python, программирования, компьютерного искусства, функциональной.

# fibonacci_sequence.py
#   This program computes the nth Fibonacci number where n is a value input
#   by the user using a function.
# by: Scott Gordon

def main():
    print("***** Welcome to the Fibonacci Sequencer *****")

    nterms = int(
        input("Enter a number to represent the number of passes through the"
              "Fibonacci Sequence you want: "))

    def fibonacci_sequence(nterms):

        counter = 0
        first = 0
        second = 1
        temp = 0

        while counter <= nterms:
            print(first)
            temp = first + second
            first = second
            second = temp
            counter += 1

    fibonacci_sequence(nterms)


main()

Фотография Людде Лоренц на Неспособный

Оригинал: “https://dev.to/sagordondev/fibonacci-sequence-function-135h”