A series in which each number is the sum of preceding two numbers is called Fibonacci series.
每个数字都是前两个数字的和的序列称为斐波那契数列。
For example: 0 1 1 2 3 5 8 13 . . . . .
例如:0 1 1 2 3 5 8 13。 。 。 。 。
Below is the program to find fibonacci series in C++.
下面是在C ++中查找斐波那契数列的程序。
#include<iostream>
using namespace std;
int main()
{
long n,first=0,second=1,third;
cout<<"How many numbers?";
cin>>n;
cout<<"Fibonacci series\n"<<first<<" "<<second;
for(int i=2;i<n;++i)
{
third=first+second;
cout<<" "<<third;
first=second;
second=third;
}
return 0;
}
Output
输出量
How many numbers?5
有多少个数字?5
Fibonacci series
斐波那契系列
0 1 1 2 3
0 1 1 2 3
翻译自: https://www.thecrazyprogrammer.com/2011/03/c-program-to-print-fibonacci-series.html