Given a set *S _{n}* of

The number of these possible groupings *G _{i}* is virtually infinite and can be virtually infinite also the number of their elements.
But in many operational situations there are more or less explicit formation rules that limit their number so that these groupings can be counted.

For example, given the set of the letters of the Latin alphabet, you can build sequences representing the words of the English language.
The number of possible words is not limited a priori, nor is their length.
Theoretically you can create more or less fanciful neologisms, but, in general, if you want them to be understandable, their composition and their length can not be arbitrary
not only by the need that every word is has a meaning, but also by the phonetic and orthographic compatibility.
For example, it will be difficult that a sequence as *hgtkx* (unless it is a particular acronym) is included in a vocabulary.

We can exactly calculate the number `E`

of the *G _{i}* only if we explicitly define the method we use to make them.

The formal development of this subject made in the second half of last century, mainly by Giancarlo Rota, is known as Twelvefold way. Here we are limited to the most basic and intuitive arguments.

The most restrictive rule is to establish that the sets *G _{i}* must be subsets of S such that they constitute
a partition of S, that is

- ∀
*i*,*G*≠ ∅_{i} *h*≠*k*⇒*G*∩_{h}*G*= ∅_{k}

This case is treated the page Partitions of this site.

If we admit that the elements of *S* are all distinguishable and that the sets *G _{i}* may have elements in common,
their number can be limited by setting the number

The result of the the counting varies according to the way in which the sets are formed and evaluated. In particular:

- if we distinguish two groups with the same elements but in different order, that is if we count the different
sequences we can form, we count the
**permutations**; - if we distinguish two groups only if they have different elements, we count the
**combinations**.

Moreover, if we form the groups *G _{n,k}* taking only once the elements of

In order to obtain the number of the groups we can form in these different ways, it is useful to calculate the
**factorial** of a natural number *n*.

Given the natural number *n*>0, its factorial, written as ** n!**, is the natural number
given by the product of all the natural numbers

Obviously

If *n*>1, we have

If we want to extend the validity of this equality to the number *n*=1, we must admit that

If *k*<*n*,

L. Euler was able to generalize the calculation of the factorial also for real and complex number by defining the function Γ (Gamma).

Given a set *S _{n}* of

In particular, if we write as *P _{n,n}* the number of the different ways of arranging all the

By induction:

- it is obvious that P
_{1,1}=1=1! if we add another element to the set

*S*, from each sequence_{n}*P*we can obtain_{n,n}*n+1*new different sequences, each of them with*n+1*elements. So the permutations*P*are_{n+1,n+1}- Therefore, by induction, the equality (2.1) is valid for all
*n*≥1.

If the elements of *S _{n}* are not all different from each other, but, for example,

If the elements of *S _{n}* are all different from each other and

and therefore

Obviously if *k*=*n* the equality (1.10) gives

Given a set *S _{n}* of

In order to calculate *C _{n,k}*, we observe that from each subset with

and therefore

The numbers *C _{n,k}* coincide with the numbers of the
Pascal's triangle,
used to expand the n-th power of a binomial, so they are usually referred as

Given a set *S _{n}* of

Such permutations are considered different if they have different elements or, otherwise, if their elements have different order.

We will write the number of such permutations as *P' _{n,k}*.

To calculate such number, we observe that, given a permutation with *k* elements, we can obtain
*n* permutations with *k+1* elements by appending to it any of the *n* elements of *S _{n}*.

Since

from the equality (4.1) we have

In general

Given a set *S _{n}* of

Such combinations are considered different **only if they have different elements**.

We will write the number of such combinations as *C' _{n,k}*.

This number is the same we would get if we were to calculate the simple combinations with *k* elements
from a set *S _{n+k-1}* formed by

For example, given the set *S _{n} = {a,b,c}*, a possible combination with