Example 2, PHP lottery program algorithm 2
The above code is a classic probability algorithm, $proArr is a The preset array, assuming the array is: array(100,200,300,400), starts by screening the first number from the probability range of 1,1000 to see if it is within its occurrence probability range. If not, the probability is reduced. That is, the probability space is the value of k minus the number just now. In this case, it is minus 100. That is to say, the second number is filtered within the range of 1,900. In this way, until the end, there will always be a number that meets the requirements. It's like touching something in a box. If the first one isn't right, the second one isn't right, and the third one isn't right, then the last one must be. This algorithm is simple and very efficient. The key is that this algorithm has been applied in previous projects, especially in projects with large amounts of data. The efficiency is very good. |