' Nth root DECLARE FUNCTION NthRoot (N%, X#, Precision#) AS DOUBLE X# = 144 PRINT "Finding the nth root of ";X#;" to 6 decimal places" PRINT " x n root x ^ (1 / n)" PRINT "--------------------------------------" FOR I% = 1 TO 8 PRINT FORMAT$("%3d ", X#); PRINT FORMAT$("%4d ", I%); PRINT FORMAT$("%10.6f", NthRoot(I%, X#, .0000001)); PRINT FORMAT$(" %10.6f", X# ^ (1 / I%)) NEXT I% input X# END FUNCTION NthRoot (N%, X#, Precision#) AS DOUBLE ' Returns the Nth root of value X to stated Precision X0# = X# X1# = X# / N% ' initial guess WHILE ABS(X1# - X0#) > Precision# X0# = X1# X1# = ((N% - 1) * X1# + X# / X1# ^ (N% - 1)) / N% WEND NthRoot = X1# END FUNCTION