math - Summation equation in Java? -



math - Summation equation in Java? -

i know how go writing addition equation in java. but, trick is, need addition equal amount.

x= total loss streak amount sb= starting bet m= multiplier

the whole equation equal current amount of currency in one's account. amount of times addition can finish while adding needs less or equal amount of currency in ones account.

fyi, dicebot work's on peerbet.org , want able show user how many times can loose in row without wasting money.

if question bad, please not reply , allow me delete it. also, thought middle part code, had set such or wouldn't allow me post.

renaming sb b. sum of geometric progression

in java, can write:

class="lang-java prettyprint-override">return b * (m * m - math.pow(m, x + 1)) / (1 - m);

this considerably faster using loop, although must check m not 1.

if want solve x given sum s rearrangement of formula gives next java code:

class="lang-java prettyprint-override">double x = math.log(m * m - s * (1 - m) / b) / log(m) - 1;

and truncate result integral value of x next integer bankrupts player.

java math calculus

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -