Hello good afternoon. I dont understand this sentence
"" return <-(b*Power(b,x-1)) """
In the video it says that the base is multiplied by the base..., and the x I guess would be the number of times the base is multiplied by itself, right? Let's suppose that the base is 2, and the exponent is 3. 2 * 2=4.. where does that four stay until it is multiplied by 2 again?
Or the x that function fulfills? Thank you.
Don't know at present. There are all sorts of ways to calculate powers, some recursive. Please copy the code into text because the screenshot isn't easy to read. Also what language is it?
First: Please post code and/or error messages as text instead of pictures. This makes it easier to analyze and read (especially on mobile devices). Please use code-tags when posting code.
Second: This is a recursive function. Each iteration is pushed onto the stack and held there until the next level down returns. This keeps recursing until the final exit condition is met (usual a counter hit 0). In simple maths raising a base to an exponential power is just one step more as multiplying: Multiplication is adding a number N byitself X times. Exponentiation is the same but the base operation is multiply instead of add - which in term gets broken down into consecutive additions. Or in other terms: Exponentiation is adding a number N X times to itself - repating that E times.
So when raising 3 to the power of 3 that is 3x3x3 = (3+3+3)+(3+3+3)+(3+3+3) = 27.
Doing it recursive is by using the exponent E as counter and call the recursive function by subtracting 1 each time.
As by definition raising N to the power of 0 results in 1. Raising N to the power of 1 results in N itself.
Campbell Ritchie wrote:Don't know at present. There are all sorts of ways to calculate powers, some recursive. Please copy the code into text because the screenshot isn't easy to read. Also what language is it?
It is a program that uses pseudocode. It's called PSEINT. OK thanks I get on mind
Campbell Ritchie wrote:Don't know at present. There are all sorts of ways to calculate powers, some recursive. Please copy the code into text because the screenshot isn't easy to read. Also what language is it?
It is a program that uses pseudocode. It's called PSEINT. OK thanks I get on mind
I understood that counters are written like this:
accumulator ← accumulator + X .
In this example, I thought it was building up on the word power:
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Gift giving made easy with the permaculture playing cards