How to represent this with math notatation

  • Thread starter moni94
  • Start date
In summary, the conversation discusses the use of pseudocode to represent a mathematical concept and how to calculate the total price of buildings in a game with increasing costs. It is suggested to use a sequence with a formula of ni+1=ni + ni * a and then finding the first number ni that meets the criteria of ni-1 ≤ k and ni > k. Alternatively, the formula \left\lfloor \frac k {n_0 \ln(1 + a)} \right\rfloor is also given as a solution.
  • #1
moni94
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)?
 
Mathematics news on Phys.org
  • #2
That's not good code. It didn't initialize n.
Maybe it was intended to compute [tex] a^{k-1} [/tex]
 
  • #3
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
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.
 
  • #5
Ok n < k.
 
  • #6
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
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:

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

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

Just out of curiosity - what did you need it for?
 
  • #9
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:.
 

FAQ: How to represent this with math notatation

1. How do I represent a variable in math notation?

In math notation, variables are typically represented by letters such as x, y, or z. They are used to represent unknown quantities or values that can vary.

2. What is the difference between an equation and an expression?

An equation is a mathematical statement that shows the equality between two expressions, while an expression is a combination of numbers, variables, and operators. In other words, an equation has an equal sign, while an expression does not.

3. How do I represent a fraction in math notation?

Fractions can be represented using the division symbol (/) or by using a horizontal line with the numerator and denominator written above and below, respectively. For example, 1/2 or 1/2.

4. What is the order of operations in math notation?

The order of operations in math notation is as follows: parentheses, exponents, multiplication and division (from left to right), and addition and subtraction (from left to right). This is commonly remembered by the acronym PEMDAS.

5. How do I represent a square root in math notation?

A square root can be represented using the radical symbol (√) or by using fractional exponents. For example, the square root of 9 can be written as √9 or 91/2.

Similar threads

Replies
5
Views
2K
Replies
1
Views
874
Replies
1
Views
853
Replies
4
Views
1K
Replies
5
Views
1K
Replies
5
Views
2K
Back
Top