# coding=gbk # 迭代法---1 def fibonacci (n): if n == 0 or n == 1: return n else : a = 0 b = 1 for i in range (n-1) : t = a a = b b = a + t return b number = eval (input ("请输入您要计算的斐波那契数列的项\n")) cc= fibonacci (number) print (cc) # 迭代法---2 def fibonac
Fibonacci Sequence # fibonacci sequence 斐波那契数列 def fibonacci_for(n): # 使用for循环返回n位斐波那契数列列表 li = [] for i in range(n+1): if i == 0 or i == 1: li.append(1) else: li.append(li[i-2] + li[i-1]) return li def fibonacci_sequence(over, x=1, y=1): # 返回一个over值
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 斐波那契数列求和 { class Program { static void Main(string[] args) { Console.WriteLine()); Console.WriteLine()); Console.WriteLine()