1 response
Dear Saqi,
Please consider going through the following sample and
hence have the solution of your problem.
#include<iostream>
using namespace std;
int fibonacci(int n)
{
int x1 = 0, fib;
int x2 = 1;
if(n >= 1)
{
for(int i=2;i<= n; i++)
{
fib = x1+ x2;
x1 = x2;
x2 = fib;
}}
return fib;
}
int main(){
for(int i=2;i<=10;i++) {
cout<<fibonacci(i)<<endl;
}
return 0;
}
Hope that the information provided proves useful to you.
Thank you.
Please consider going through the following sample and
hence have the solution of your problem.
#include<iostream>
using namespace std;
int fibonacci(int n)
{
int x1 = 0, fib;
int x2 = 1;
if(n >= 1)
{
for(int i=2;i<= n; i++)
{
fib = x1+ x2;
x1 = x2;
x2 = fib;
}}
return fib;
}
int main(){
for(int i=2;i<=10;i++) {
cout<<fibonacci(i)<<endl;
}
return 0;
}
Hope that the information provided proves useful to you.
Thank you.