Course Solutions Uncategorized (Solved) : Consider Following Iterative Function Int Pentagonal Int N Int Result 0 Int 1 Q26196737 . . . .

(Solved) : Consider Following Iterative Function Int Pentagonal Int N Int Result 0 Int 1 Q26196737 . . . .

 

Consider the following iterative function: 


int pentagonal(int n) {


     int result =0;

     for (int i =1; i <= n; i++)


      result += 3 * i – 2;

     returnresult;


}

Rewrite the function pentagonal using recursion and addpreconditions and postconditions as comments. Then prove byinduction that the recursive function you wrote is correct.

Please ensure you include the preconditions andpostcondtion comments and clearly prove byinduction step by step.

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post