Ask your own question, for FREE!
Mathematics 21 Online
OpenStudy (lgbasallote):

Discrete Mathematics question: How to write a step-by-step algorithm for raising a certain number to a certain exponent?

jhonyy9 (jhonyy9):

how do you think it please ?

jhonyy9 (jhonyy9):

...for example ?

OpenStudy (anonymous):

def exponent(number, power) return number**power There you are, algorithm:-)

OpenStudy (lgbasallote):

that seems a bit short @estudier isn't it? i mean the algorithm loops doesn't it?

OpenStudy (anonymous):

It's a function, you call it, like exponent(3,6) and it returns 3^6 I am not really sure what you are looking for to be honest. Any program code can be rewritten as an algorithm.

OpenStudy (anonymous):

would a javascript code help? lol

OpenStudy (lgbasallote):

really?

OpenStudy (lgbasallote):

and i prefer c @gaara438125

OpenStudy (lgbasallote):

but an algorithm has to be detailed enough for a program to run right @estudier ?

OpenStudy (anonymous):

i prefer C++ lol

OpenStudy (anonymous):

@lgbasallote A function is a built in type in many programming languages ( bit like math, really) Most higher level programming languages are abstract or "high-level". I mean, in theory, you could write the algorithm in machine language but it would be very long and completely incomprehensible.

OpenStudy (lgbasallote):

hmm fair enough

OpenStudy (anonymous):

I can execute that code on my computer just as it is but it does rely on the language framework having already been set up on my computer.

OpenStudy (lgbasallote):

i just couldn't figure out how to initiate my loop....

OpenStudy (lgbasallote):

i thought discrete math algorithm could help....

OpenStudy (anonymous):

Oh, I see, your are dropping a level of abstraction....

OpenStudy (anonymous):

You want to do it as repeated multiplication or something like that?

OpenStudy (lgbasallote):

yes...something like that

OpenStudy (anonymous):

Here is one I just lifted off the web int powerFunc(int x, int y) { for (int i = 0; i < x; i++) { sum *= y; // here it will keep mulitplying itself until // the condition is met } return (sum); } your main would look like this: int result = powerFun(x,y);

OpenStudy (anonymous):

This is still relying on a function call to work but has a loop structure...

OpenStudy (lgbasallote):

no idea what that means////

OpenStudy (anonymous):

ie the bit about multiplying until a condition is met.....

OpenStudy (lgbasallote):

nevermind the question....i'll just try to think about it

OpenStudy (anonymous):

K.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!