6 Replies Latest reply on May 10, 2012 1:32 PM by raybaudi

# How to get all possible combinations of 20 numbers ?

### Title

How to get all possible combinations of 20 numbers ?

### Post

What I want is to get ALL possible combinations of 20 numbers, in groups of 5 numbers.

How can I do that? The numbers should be in order - from minor to the largest, without any number repeated.

So, if I have numbers 1...to 20, I want

1-2-3-4-5

1-2-3-4-6

1-2-3-4-7

and so on.

Thank you very much

• ###### 1. Re: How to get all possible combinations of 20 numbers ?

There are 55 possible numbers for the first number, 54 for the second, and so on to 50 possibilities for the sixth number, giving 55 x 54 x ... x 50 different possible ways of selecting six numbers from fifty five different numbers.

However, as the order of selection does not matter (the combinations {1, 2, 3, 4, 5, 6} and {6, 5, 4, 3, 2, 1} are considered the same) the first number could appear in any of the six positions, the second in any of the remaining 5, and so on until there is only 1 place left for the last number, giving 6 x 5 x ... x 1 different ways each six digit combination will appear in the selections above, so the total number of ways of combining six numbers from fifty five different numbers is:

combinations = (55 x 54 x ... x 50) ÷ (6 x 5 x ... x 1)
= 28,989, 675

Five combinations are:

{1, 2, 3, 4, 5, 6},
{1, 2, 3, 4, 5, 7},
{1, 2, 3, 4, 5, 8},
{1, 2, 3, 4, 5, 9},
{1, 2, 3, 4, 5, 10}

I'll leave the remaining twenty eight million, nine hundred and eighty nine thousand, six hundred and seventy (28,989,670) combinations for you to list.

Where the order of selection matters, it is called a permutation. The formula to calculate the permutation of r items selected from a total of n items is:

nPr = n!/(n-r)!

Where the order of selection does not matter, it is called a combination. The formula to calculate the combination of r items selected from a total of n items is:

nCr = nPr ÷ r! = n!/(n-r)!r!

In both the above formulae the exclamation mark is the factorial of the preceding number which is the number multiplied by all positive numbers less than it, for example 5! is five factorial:

5! = 5 x 4 x 3 x 2 x 1
= 120
• ###### 2. Re: How to get all possible combinations of 20 numbers ?

Combinations and Permutations Calculator

http://www.mathsisfun.com/combinatorics/combinations-permutations-calculator.html

## Types to choose from? 20Number Chosen? 5Is Order important? YesIs Repetition allowed? NoAnswer: 1,860,480

• ###### 3. Re: How to get all possible combinations of 20 numbers ?

The same url gives also this ( I think that it answers better your question ):

`Types to choose from? 20Number Chosen? 5Is Order important? NoIs Repetition allowed? NoAnswer: 15504`
`And , if you List Them ( 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ), you'll get a .txt file with all the 15.504 combinations.`
• ###### 4. Re: How to get all possible combinations of 20 numbers ?

Thank you to everybody that replied.

I didn´t  want to KNOW how many combinations I will get, but HOW to get the combinations WITH FILE MAKER.

Could I use the formula David Danders gave to me?

nPr= n/(n-r)!

File Maker has this formula?

• ###### 5. Re: How to get all possible combinations of 20 numbers ?

I checked File Maker and found this formula to factorial:

Factorial ( number {; numberOfFactors} )

How this relates with your formula, David?

• ###### 6. Re: How to get all possible combinations of 20 numbers ?

The formula to obtain the number of combinations is:

Factorial ( n ; r ) / Factorial ( r )

that, in your case, returns 15,504.

But to get the combinations you'll need a script with loops or, simpler, import the csv file generated by the url above.