Algorithm to find amount of unique number sequences without repeating numbers?

283 Views Asked by At

Basically what I am wondering is what the algorithm would look like to find the amount of number sequences without repeating numbers for any given positive number?

For Example, if you use 3 (which will use all numbers between 1-3): you get 6 possible outcomes: {1,2,3}, {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1}

Another Example with 4 will result in 24 possibilities: {1,2,3,4}, {1,2,4,3}, {1,3,2,4}, {1,3,4,2}, {1,4,2,3}, {1,4,3,2}, etc.

Is there an algorithm that can find this amount? Thank in advance and hopefully this wasn't a blatantly obvious answer.

1

There are 1 best solutions below

1
On BEST ANSWER

Have a look at the Wikipedia article about the factorial. The first mentioned application is:

There are $n!$ different ways of arranging $n$ distinct objects into a sequence, the permutations of those objects.