|
-
Mar 8th, 2023, 05:12 PM
#1
[RESOLVED] Excel VBA code for n taken r at a time
When choosing 3 balls out of 5 where order does not matter and without repetitions:
----------
# combinations = nCr
= n!
(n-r)! r!
= 5!
(5-3)! 3!
= 5!
2! 3!
= 10
Does anyone have VBA code that will generate the 10 combinations? The code needs to be flexible so that n and r can vary. For example if the 'n' numbers were 10 20 30 40 and 50, and 'r' is 3 the result should be:
10 20 30
10 20 40
10 20 50
10 30 40
10 30 50
10 40 50
20 30 40
20 30 50
20 40 50
30 40 50
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|