Summation equation in Java?

I want to know how to write this summation equation in Java But the trick is, I need the sum equal to the amount

x= Total Loss Streak amount
sb= Starting Bet
m= multiplier

The entire equation will equal the current amount of money in an account The number of times that the sum can be completed at the time of aggregation needs to be less than or equal to the amount of money in an account

FYI, this is one in peerbet Org, I hope to show users that he can loose many times in a row without wasting all his money

If this question is not good, please don't answer, let me delete it In addition, it thinks the middle part is code, so I have to do this or it won't let me release

Solution

Rename sb to B. This is just the sum of geometric series

In Java, you can write:

return b * (m * m - Math.pow(m,x + 1)) / (1 - m);

This will be much faster than using loops, but you must check that M is not 1

If you want to solve x given and s, the rearrangement of the formula will give the following java code:

double x = Math.log(m * m - S * (1 - m) / b) / log(m) - 1;

The result is truncated to obtain the integer value of X, where the next integer destroys the player

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>