Reputation: 2360
Given function:
y=power(x, z)
Where y is the base x raised to the power of z.
In Java and many other language, there is function Math.pow() to calculate this.
My question is: how to calculate x, given y and z? Is there a standard library function for this?
Upvotes: 0
Views: 307
Reputation: 20520
This is done easily enough by remembering a mathematical law:
And now because z*(1/z)=1, the inverse of raising to the power z is raising to the power 1/z. So in your case
Once you've got your power()
function, that's all you need.
Upvotes: 2