$ ./tree Enter height of tree: 10 * *** ***** ******* ********* *********** ************* *************** ***************** *******************The source code is given here.
The formula for n choose k is $$\frac{n\cdot(n-1)\cdot(n-2)\cdots(n-k+1)}{k\cdot(k-1)\cdot(k-2)\cdots 1}$$
So, for example 7 choose 3 is (7*6*5)/(3*2*1) = 35.
Notice that this number will always be an integer! So do all of your
computations using type int, and don’t do anvy division
unless you're sure you'll get exact results, i.e. no remainder.
Sample run:
$ ./binom Please enter n: 4 Sum as k goes from 0 to 4 is 16 $ ./binom Please enter n: 9 Sum as k goes from 0 to 9 is 512Take a look at this solution to the problem.
~/$ ./p3 Enter a number: 5 @...@ .@.@. ..@.. .@.@. @...@ |