Number of ways to choose five lottery numbers so no two are adjacent Someone stated that in a lottery draw, you have an equal chance of being 1 off of every correct number as you do of actually winning, but this is not true if you have adjacent numbers (such as 7/8). I wrote a program which iterates over all possible numbers and counts the number of outcomes where two numbers are adjacent given a top number. It would be too time-consuming to check all 50 numbers for each 5 possible selections, so I instead used lower numbers and tried to find an equation which I can use.
I've got a dataset of x and y values (where x = top number and y = number of outcomes with atleast one adjacent pair). I believe this dataset turns into a quintic function (x^5) when plotted, but I'm not sure. I have two main questions:

*

*How could I find the equation of the graph? I have tried to find the difference of differences (similar to quadratic, ie 1, 4, 9, 16 = 3, 5, 7 = 2) and it turned out that the difference after 5 differences was a constant 120. I have also tried to find the ratio of one number to the next. This leads to my next question...


*This ratio turned out to be strangely nice. When x=8, y=0. x=9,y=120. x=10,y=720. x=11,y=2520. If you divide one number by the previous, you get *6 (6/1), *3.5 (7/2) and so on, (8/3, 9/4). The fraction's denominator and numerator increase by 1 every time. Where does this come from?
Code I used (python) - https://pastebin.com/d2bAQVmV
 A: You are choosing five numbers between $1$ and $x$, and asking the number of ways where no two of the chosen numbers are either equal or adjacent. The answer is
$$
\binom{x-4}{5}\cdot 5!=x(x-1)(x-2)(x-3)(x-4)
$$
It is well known that, for positive integers $k$ and $x$, the number of unordered selections of $k$ distinct numbers from $\{1,\dots,x\}$ where no two selected numbers are adjacent is $\binom{x-k+1}{k}$. See the sources belwo for a proof. To get the number of ordered selections, you just multiply by $5!$, the number of ways to arrange five numbers, resulting the formula above. This is a degree five polynomial in $x$, as you noticed.
Questions on MSE on counting non-consecutive subsets:
Combinatorial restriction on choosing adjacent objects
How many $5$ element sets can be made?
Analysis of formula for selecting $k$ elements from $n$ elements arranged in a row so that no two selected elements are consecutive

Edit: Everything in this section is only correct for lotteries where the order of the chosen numbers matters.
By the way, the statement "you have an equal chance of being 1 off of every correct number as you do of actually winning" is indeed true, if you interpret it a specific way. Suppose ticket has the numbers $(a,b,c,d,e,f)$. The probability of drawing $(a,b,c,d,e,f)$ is the same as the probability of drawing $(a+1,b+1,c+1,d+1,e+1,f+1)$.
There is a small caveat here; the "+1" must be interpreted modulo $x$. For example, if there were fifty possible lottery numbers, then you would have to say that $50+1$ wraps around back to one.
