Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
25
Task/Nth-root/RapidQ/nth-root.rapidq
Normal file
25
Task/Nth-root/RapidQ/nth-root.rapidq
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue