29.(C)Pascal triangle --->>>Finding the sum of any row of pascal triangle
include <stdio.h>
#include<math.h>
/*Given an integer N,
print the sum of the Nth row of the Pascal's triangle.
In mathematics, Pascal's triangle is a triangular
array of the binomial coefficients. Below are the
first few rows of the Pascal's triangle:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
The numbers on the edges of the triangle are always 1.
Each of the remaining numbers are
the sum of the two numbers that appear immediately above it.
The sum of the 5th row, for example,
is 1 + 4 + 6 + 4 + 1 = 161+4+6+4+1=16.
Input
The input will contain
one integer N (0 < N < 30).
Output
Print the sum of the Nth row of Pascal's triangle.*/
int main() {
int N,sum;
scanf("%d",&N);
sum=pow (2,N-1);
printf("%d",sum);
return 0;
}
Enter
Write to Mohammad Sifat
- Get link
- X
- Other Apps
Comments
Post a Comment