Python 斐波那契数列:计算第一个大于输入值的项
def fibonacci(n): a, b = 1, 1 while a <= n: a, b = b, a + b return a
n = int(input('请输入一个数:')) result = fibonacci(n) print('斐波那契数列中第一个大于' + str(n) + '的项为:' + str(result))
原文地址: https://www.cveoy.top/t/topic/f4nD 著作权归作者所有。请勿转载和采集!