How to represent this with math notatation

  • Thread starter moni94
  • Start date
  • #1
8
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)?
 

Answers and Replies

  • #2
Stephen Tashi
Science Advisor
7,389
1,367
That's not good code. It didn't initialize n.
Maybe it was intended to compute [tex] a^{k-1} [/tex]
 
  • #3
5
0
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:
  • #4
Stephen Tashi
Science Advisor
7,389
1,367
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.
 
  • #5
5
0
Ok n < k.
 
  • #6
I like Serena
Homework Helper
6,577
176
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:

[tex]\left\lfloor \frac k {n_0 \ln(1 + a)} \right\rfloor[/tex]
 
  • #7
8
0
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:

[tex]\left\lfloor \frac k {n_0 \ln(1 + a)} \right\rfloor[/tex]
Thanks, that's what I needed!
 
  • #8
I like Serena
Homework Helper
6,577
176
Thanks, that's what I needed!
Just out of curiosity - what did you need it for?
 
  • #9
8
0
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
I like Serena
Homework Helper
6,577
176
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:.
 

Related Threads on How to represent this with math notatation

Replies
6
Views
889
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
4
Views
1K
Replies
2
Views
1K
Replies
7
Views
975
Replies
1
Views
2K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
2
Views
2K
Replies
5
Views
2K
Replies
2
Views
2K
Top