First we are going to make some obvious restriction:

$$m \le k \le n$$

Note that if we choose the first number then the following $m-1$ numbers can't be chosen. For example in your example if we choose $2$ to be our first number, then it implies that $3,4,5,6$ are the second, third, fourth and fifth number respectivly.

There are $n-m+1$ to choose the first number, because if we choose a number greater that $n-m$ then we can't choose $m$ consecutive number starting with that one.

Now it's we need to chose $n-m$ random numbers for $k-m$ places.

Because you've mentioned lottery tickets, where the order isn't important we'll assume that in the calculation the order isn't important.

First I want you to note something. I'll again use your example. We take numbers from 1-5 as consecutive and we'll place them in the first 5 places, and then some random number but for the purpose of presentation we'll choose 6. Then the set will be:

$${1,2,3,4,5,6}$$

Now let's think like these, we'll choose the numbers from 2-6 and will place them in the last 5 places and the random number will be 1. The set then will be;

$${1,2,3,4,5,6}$$

Aren't this sets the same? But we choose the using 2 different ways, so that means we'll make some restrictions and we'll make 2 cases.

**Case 1: $k=m$**

Obviously we have space only to place the consecutive number so let $P(n,k,m)$ represent the number of ways to choose $k$ numbers out of $n$ numbers with $m$ consecutive numbers, so we have:

$$P(n,k,m) = n-m+1$$

**Case 2: $k \ge m+1$**

Note that if $1$ is the first number of the series we can't choose the predecessor, because there isn't one. So we have:

$$P(n,k,m) = (n-m) \times \binom{n-m-1}{k-m} + \binom{n-m}{k-m}$$

And if we calculate for your example we have:

$$P(49,6,5) = (49-5) \times \binom{49-5-1}{6-5} + \binom{49-5}{6-5}$$
$$P(49,6,5) = 44 \times \binom{43}{1} + \binom{44}{1}$$
$$P(49,6,5) = 44 \times 43 + 44$$
$$P(49,6,5) = 1936$$

The probability that a number has at least one $1$, at least one $2$, and at least one $0$ is $1$ minus the probability of having no $0$'s, **or** no $1$'s, **or** no $2$'s. So, label $A$ as the event "no zeros", $B$ as the event "no ones", $C$ as the event "no twos".
You want:
$$
1-P(A\cup B\cup C) =1-\left(P(A) + P(B) + P(C)\right) +\left(P(A\cap B) + P(A\cap C) + P(B\cap C)\right) - P(A\cap B \cap C) = 1-\frac{ 9^6+2\cdot 8\cdot 9^5 }{9\cdot 10^5}+\frac{2\cdot 8^6+7\cdot 8^5}{9\cdot 10^5} -\frac{7^6}{9\cdot 10^5}= \frac{1993}{30000}
$$

## Best Answer

Let $A,B,C$ be the set of the numbers which have no $0$, no $1$, no $2$ respectively. Also, let $n(A)$ be the number of the elements of $A$.

Then, find the following value $Z$ :

$Z=n(A)+n(B)+n(C)-n(A\cap B)-n(B\cap C)-n(C\cap A)+n(A\cap B\cap C).$

Then, the answer will be $9999-1000+1-Z$.