Question: if ( n < 0 ) return - 1 ; / / declare int variable term 1 , term 2 and nextTerm / / initialize
ifn
return ;
declare int variable termterm and nextTerm
initialize termterm with and
int termtermnextTerm;
for loop iterate n times
forint i;in;i
nextTerm is calculated by adding term and term
nextTermtermterm;
set term value as new term
termterm;
set nextTerm value as new term
termnextTerm;
return term;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
