PASSAGE
function Fibonaccinum)
1. if (num equals 0
2. then return 1
3 else if(n equals 1)
4. then return
1
5. else return Fibonaccin 1 - Fibonaccn2
Answers
Answer:
Mark as Brainliest, it really motivates!
Answer:
The answer to the given question will be a program.
Explanation:
Given :
PASSAGE
function Fibonaccinum)
1. if (num equals 0
2. then return 1
3 else if(n equals 1)
4. then return 1
5. else return Fibonacci 1 - Fibonaccn2
To find:
Using the above conditions we have to create a program.
solution :
The given program is a Fibonacci program
this was the main example of a c++ which is an object-oriented programming language.
let us write coding in cpp language.
int main(){
int n, t1=0,t2=1,nextTerm=0;
cout<< "Enter the number of terms:";
cin>>n;
cout<<" Fibonacci Series:";
for(int i= 1;i<=n;++i){
//prints the first two terms.
if(i==1){
cout<<t1<<",";
continue;
}
if(i==2){
cout<<t2<<",";
continue;
}
nextTerm= t1+t2;
t1=t2;
t2= nextTerm;
cout <<nextTerm<<",";
}
return 0;
}
Therefore, the above-given program is the correct answer for the given question.
# spj5