Simple code needs to convert into loop from recursive function -
can convert recursion iteration?
begin seq(n) if (n equals 1) return 3 elseif (n equals 2) return 2 else return seq(n – 2) + seq(n – 1) endif end
these fibonaccis starting 3,2, going 5, 7 etc. set if passed n, if n 1 or 2 make special case, , otherwise like: a=3 b=2 (i leaving figure out indices) {temp=b; b=b+a;a=temp} return b
i not want more since seems homework problem , answers not supposed of work.
Comments
Post a Comment