Use induction to prove the following:
- Prove that the sum of the first n odd integers is n2
writing a proof and then a program to go along with it.
Program
#include <stdio.h>
#include <math.h>
int main()
{
int i, num, sum=0, sqr=0;
printf("Enter Value Of N: ");
scanf("%d", &num);
i=num;
while(i>0)
{
sum = sum + ((i * 2)-1);
i--;
}
printf("\nSum of First %d odd numbers is =
%d\n",num ,sum);
sqr = num*num;
printf("\nSquare Root of %d is = %d\n",num,
sqr);
return 0;
}
OUTPUT
We need to Prove the following
1+3+5+...+(2n-1) =n2
1=1=12
1+3=4=22
1+3+5=9=32
1+3+5+7=16=42
1+3+5+7+9=25=52
So the Answer is 1+3+5+...+(2n-1) = n2
Proof
Step 1.
For n = 1 it's true that 1 = 2*1-1
Step 2.
We suppose that 1+3+5+...+(2n-1) = n2 and need to prove
the equation 1+3+5+...+(2(n+1)-1) = (n+1)2
Hence if we add (2(n+1) -1) to the equation it becomes
1+3+5+...+(2n-1) = n2
And the equation becomes
1+3+5+...+(2n-1) + (2(n+1) -1) = n2 + (2(n+1)
-1)
After Simplification
1+3+5+...+(2(n+1) -1) = n2 + 2n+2 -1
but we have n2+2n+1 = (n+1)2
So it proves our theorm.
1+3+5+...+(2(n+1)-1) = (n+1)2
Get Answers For Free
Most questions answered within 1 hours.