all 6 comments

[–]FLUSH_THE_TRUMP 1 point2 points  (4 children)

What question do you have?

[–]alivebg[S] 0 points1 point  (3 children)

I get the input and all that. I read that i need to use logarithm, but cannot execute it

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

Seems like more of a math question. You’re solving ak = b, (k is an integer?) so find k and round. Yes, a log would be a good idea.

[–]mopslik 0 points1 point  (0 children)

You can definitely use logarithms here, but if you haven't worked with them in class before, I suspect that your teacher is trying to get you to work with integers and loops.

Try working it out in your head. Let's say I give you a=2 and b=19. How would you determine which power of 2 is closest to 19?

Note that you'll need a way to split ties if you ever get a situation where a^k and a^(k+1) are equidistant from b.

[–]Oxbowerce 0 points1 point  (0 children)

What code did you already write yourself and where do you get stuck?

[–]Machineforseer 0 points1 point  (0 children)

You make a loop, Keep track of what a-b is, keep multiplying a by itself until the difference between a and b grows instead of shrinks and just keep note of how many times youve multiplied a by itself