
10-09-2003, 04:12 AM
|
 |
Senior Contributor
|
|
Join Date: Dec 2002
Location: Netherlands
Posts: 867
|
|
Math problem: nCr (Combinations)
I have a math related problem:
On my calculator I have the nCr function, which can calculate combinations. Is there a same function for it in vb??
An example:
I want to fill 3 squares in a 4 x 4 rectangle. On how many ways can I do this. Some possibillities are:
x - x -
- - - -
- - - -
- x - -
or
- x - x
x - - -
- - - -
- - - -
To count the number of combinations you can use the nCr functions:
Answer = (4 x 4) nCr 3 = 16 nCr 3 = 560 possibillities.
Note:
16 nCr 3 = 16! / (3! * 13!) =
(16 x 15 x 14 x 13 ... x 3 x 2 x 1) / ((3 x 2 x 1) x (13 x 12 x 11 ... x 3 x 2 x 1))
Anyone knows if this function exists in vb??
Wilbert 
|
Last edited by wilbert; 10-09-2003 at 04:52 AM.
|