Formular
We use
To see why, let’s consider the following polynomial:
If we want to find a looping range i, i.e.,
which means
Last updated
We use
To see why, let’s consider the following polynomial:
If we want to find a looping range i, i.e.,
which means
Last updated
as the lottery result, where is a polynomial evaluation, is a random u256 integer, and is a large prime number. The basic theory behind this setting is that this modulus result will generate loops when increases from to .
Equivalently, this means all the coefficients of should be . Denote the coefficients of as {}. It is easy to see that is for all is ≥ 0, is divisible by . So if we set , all will be . Therefore, will be a looping range of . Specially, if , we will have . Therefore, if there is no in , then will be the minimal looping range of .
The next step is to choose a prime such that is the minimal looping range, and the smallest probability is the only in this range) is approximately the smallest required probability. Afterwards, the remaining task is to calculate all the probabilities of the lottery results and aggregate the ranges such that each range of results satisfies the required probabilities.