blob: 363556d2cfc30daf0ccf8f1f30c2c8c6efa6815e (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
function [k]= myfunc(n,r)
k=factorial(n)/(factorial(n-r)*factorial(r));
endfunction
k=myfunc(8,3);
disp(k,'the number of committees of three that can be formed out of eight people')
cows=myfunc(6,3) //number of ways that a farmer can choose 3 cows out of 6 cows
pigs=myfunc(5,2) //number of ways that a farmer can choose 2 pigs out of 5 pigs
hens=myfunc(8,4) //number of ways that a farmer can choose 4 hens out of 8 hens
p=cows*pigs*hens;
disp(p,'total number of ways that a farmer can choose all these animals')
|