Question: PRE - condition: n > = 0 1 . long square ( int n ) { 2 . if ( n = = 0 )

PRE-condition: n >=0
1. long square(int n){
2.
if (n ==0) return 0;
3.
return square(n-1)+2* n-1;
4.}
POST-condition: Return the quantity n * n.
In other words, assuming N = n, the square algorithm should return N2.
Let P(N)= square(N) returns N2, for any integers N >=0.
Use P(N) as its defined to prove, using strong mathematical induction, that square
correctly satisfies the POST-condition

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!