Home >Web Front-end >JS Tutorial >Use js to generate a list of random lottery numbers_javascript skills
The friend said his friend shouted the question. Lottery shop, I want to print out a list.
There are 22 balls numbered 1-22. Take 5 out randomly. Do not put it back after taking it out.
For example, the first time I took out the number 5, the second time I took it from the remaining 21 balls. And so on, a total of 5 balls are taken out.
Take out the last 5 balls, regardless of the order in which they are arranged. That is to say, if you take out 1 2 3 4 5 and 5 4 3 2 1, they are the same number. You can only print out the list once
Finally print out all the results. What he called a simple permutation and combination problem involved some operations on arrays. I was temporarily confused and couldn't think about it.
Let’s see if there is anyone who can answer the question and provide some more convenient algorithms. Thank you very much