Write a function that calculates a row of the pascal triangle and returns the middle number, if there are 2 it should return their sum.
Example:
5
would return
20
Example 2:
4
would return
6
EDIT:
To be clear:
a) if the number inputted is odd then find then return the middle number of a row on the pascal triangle.
b) if the number inputted is even then find the two middle numbers of the row on the pascal triangle and sum the 2 numbers.
The nth row is using zero-based indicies. For numbers other than zero, this is the row which has its second number as the number inputted into the function.
nC(n/2)
ifn
is even and2(nC((n-1)/2))
ifn
is odd? \$\endgroup\$