How to represent this with math notatation

  • Thread starter Thread starter moni94
  • Start date Start date
AI Thread Summary
The discussion focuses on representing a pseudocode loop mathematically, specifically for the sequence defined by n_i+1 = n_i + n_i * a, where n is initially arbitrary. The participants clarify that the goal is to find the first number N such that n_i-1 ≤ k and n_i > k, leading to the formula N = ⌊k / (n_0 ln(1 + a))⌋. The context for this mathematical representation arises from a game mechanic where building prices increase by 10% with each purchase. The final formula is crucial for calculating the total price of buildings that can be bought with a given budget. This mathematical approach effectively addresses the original pseudocode's intent.
moni94
Messages
8
Reaction score
0
Hi. I have the following pseudocode:

while(n < k)
n = n*a

How do I represent this with mathematical notation (e.g with summation)?
 
Mathematics news on Phys.org
That's not good code. It didn't initialize n.
Maybe it was intended to compute a^{k-1}
 
n is arbitrary. We're not writing a program here, I was just using pseudocode to demonstrate the concept.

Oh, and the code is supposed to be:

while(n < k)
n = n + n*a
 
Last edited:
kaloyan5 said:
n is arbitrary. We're not writing a program here, I was just using pseudocode to demonstrate the concept.

Well, if the arbitrary n starts out greater than the arbitrary k, that would be a simple concept.
 
Ok n < k.
 
Let {ni} be the sequence given by ni+1=ni + ni * a.
Let N be the first number ni such that ni-1 ≤ k and ni > k.

Or:

\left\lfloor \frac k {n_0 \ln(1 + a)} \right\rfloor
 
I like Serena said:
Let {ni} be the sequence given by ni+1=ni + ni * a.
Let N be the first number ni such that ni-1 ≤ k and ni > k.

Or:

\left\lfloor \frac k {n_0 \ln(1 + a)} \right\rfloor

Thanks, that's what I needed!
 
moni94 said:
Thanks, that's what I needed!

Just out of curiosity - what did you need it for?
 
Well there's this game where you can spend your money on buildings and each time you buy one the price of that building goes up by 10%. So I wanted to know how you can calculate the total price of the buildings you can buy with a certain amount of money.
 
  • #10
moni94 said:
Well there's this game where you can spend your money on buildings and each time you buy one the price of that building goes up by 10%. So I wanted to know how you can calculate the total price of the buildings you can buy with a certain amount of money.

Ah, so you mostly needed the final formula?
Please note, that this is the total price of the buildings which is one more than you can buy :wink:.
 

Similar threads

Replies
5
Views
2K
Replies
1
Views
626
Replies
1
Views
1K
Replies
4
Views
1K
Replies
12
Views
230
Replies
5
Views
1K
Back
Top