different ways.
If you aren't sure what !(factorial) is you can check out Factorial - Wikipedia, the free encyclopedia
Hi all, i'm new to the forum so i hope this is the correct place to post this question. If i have 15 numbers 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, how do i figure out how many different sets of 3 numbers together i can make from the 15, like 1,2,3 or 1,6,8 for example. No duplicates so for example 1,2,3 would be the same as 3,2,1 or 1,3,2 etc. Just every number with every other number once in sets of 3 numbers. How many combinations are there without replicating any? If you could explain how you got the answer too that would be great. TIA for the help, i appreciate it. Take care.
different ways.
If you aren't sure what !(factorial) is you can check out Factorial - Wikipedia, the free encyclopedia
OK thanks for the help i get it now. I have 1 more question. Is there a way to figure out what all 455 sets would be or do i just have to go thru all the numbers and match them up until i get 455 different sets? Thanks to the mod for putting this in the right place, sorry about that. Thanks again for the help everyone.
Sorry there is just no easy way to do that.
A computer can be programmed to output the list.
Here is a way to start.
Take the string that represents the set
The string that represents the set .
So any arrangement of a queue three 1’s and twelve 0’s represents one subset you want.
A pretty easy algorithm is to use a loop within a loop within a loop. A recursive solution is also possible, but is more useful for when the number 3 is not fixed.
I consider it easy enough I'll just write it now.
C++
[php]
#include <cstdio>
int main() {
int c=0,i,j,k;
for(i=1;i<=13;i++)
for(j=i+1;j<=14;j++)
for(k=j+1;k<=15;k++) {
printf("%d %d %d\n",i,j,k);
c++;
}
printf("\n%d combinations found.\n",c);
return 0;
}
[/php]
Can be run online here:
Ideone.com | LHLGK