Task

Implement the algorithm to compute the principal   nth   root   





A

n





{\displaystyle {\sqrt[{n}]{A}}}

   of a positive real number   A,   as explained at the   Wikipedia page.



FUNCTION RootX (tBase AS DOUBLE, tExp AS DOUBLE, diffLimit AS DOUBLE) AS DOUBLE
    DIM tmp1 AS DOUBLE, tmp2 AS DOUBLE
    ' Initial guess:
    tmp1 = tBase / tExp
    DO
        tmp2 = tmp1
        ' 1# tells compiler that "1" is a double, not an integer
        tmp1 = (((tExp - 1#) * tmp2) + (tBase / (tmp2 ^ (tExp - 1#)))) / tExp
    LOOP WHILE (ABS(tmp1 - tmp2) > diffLimit)
    RootX = tmp1
END FUNCTION