in reply to getting a cube root

It means this:
8**(1/3) == 81/3 == cube root of 8 == 2

Replies are listed 'Best First'.
Re: Re: getting a cube root
by Grygonos (Chaplain) on Oct 08, 2003 at 19:12 UTC

    small math lesson for AM: just incase you didn't realize, taking the nth root of anything is the same as raising that expression/number/etc..etc..etc... to the 1/n power where n is the root you are trying to find.

    to find the 5th root of x, you simply do x**(1/5), 218th root x**(1/218), you get the picture. FYI: very much respect for the question, but just not a perl way of doing it.. just a math way. You can write your own sub to do it if you really wanna make it readable for newbies or non-coders.

    #!/perl use strict; #Take the 3rd root of 8; my $root = nthRoot(8,3); print $root; #Just pull the parameters off the #@_ array as they are needed #in the return statement sub nthRoot {return (shift)**(1/shift);}