Answer the question
In order to leave comments, you need to log in
What is the mathematical formula?
Greetings,
I am developing a lottery and I am faced with the fact that I cannot find a formula for dividing the winnings between the participants, I hope for your help, here's the essence: the
2nd one gets the winnings 2 times less than the first
3rd one gets 2 times less than the 2nd
Winning: 100
winnings places: 3
Should be like this x + 2x + 4x = 100
If there are 4 winning places:
x + 2x + 4x + 8x = 100
If there are 5 winning places:
x + 2x + 4x + 8x + 16x = 100
If there are 6 winning places:
x + 2x + 4x + 8x + 16x + 32x = 100
I can't figure out what formula can be used to automatically calculate if the number of winning places varies, I hope for help from the community!
Answer the question
In order to leave comments, you need to log in
If n is the number of participants
1x+2x+4x+...+2 n-1 x = (2 n -1)x = 100
x = 100/(2 n -1)
Each winner gets ( i - taken place)
P i \u003d 2 n-i x \u003d 100 * 2 n-i / (2 n -1)
x = s / (2^(n-1) - 1)
, where s is the winning amount; n is the number of "seats".
And you try to go from the opposite. For example - the first group of winners receives "half of the prize fund". The next group is half of the remaining half, and so on. The problem will only be to set the point after which we stop dividing the prize.
In a loop from 0 to the number of places-1, you add 2 to the degree of iteration of the loop. For example for 6 places
Sting S = "";
for(int i=0;i<6;i++) {
S+=(int)(Math.pow(2,i))+"x";
}
1 + 2 + 4 + ... = 2⁰ + 2¹ + 2² + ... = 2ⁿ - 1
(2ⁿ - 1)x = 100
x = 100 / (2ⁿ -
1
) participants x = 100 / (2⁴ - 1) = 100 / 15
Winnings: 100/15, 2*100/15, 4*100/15, 8*100/15
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question