# How to represent this with math notatation

Hi. I have the following pseudocode:

while(n < k)
n = n*a

How do I represent this with mathematical notation (e.g with summation)?

Stephen Tashi
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:
Stephen Tashi
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.

I like Serena
Homework Helper
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$$

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!

I like Serena
Homework Helper
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.

I like Serena
Homework Helper
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 .