Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started