Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate nth root?

Is there a way to calculate the nth root of a double in objective-c?

I couldn't seem to find an appropriate function.

like image 608
Joseph Avatar asked Oct 23 '11 15:10

Joseph


2 Answers

You have to use the pow function:

pow(d, 1.0/n)

enter image description here

like image 167
fceruti Avatar answered Nov 26 '22 19:11

fceruti


Mathematically, the n-th root of x is x to the power of 1/n.

I have no idea what the syntax of objective-c would be, but basically you just want to use the power function with 1/n as the exponent.

like image 35
Niet the Dark Absol Avatar answered Nov 26 '22 21:11

Niet the Dark Absol