Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
24
Task/Nth-root/QuickBASIC/nth-root.basic
Normal file
24
Task/Nth-root/QuickBASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
' Nth root
|
||||
DECLARE FUNCTION NthRoot# (N%, X#, Precision#)
|
||||
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 USING "### "; X#;
|
||||
PRINT USING "#### "; I%;
|
||||
PRINT USING "###.######"; NthRoot#(I%, X#, .0000001);
|
||||
PRINT USING " ###.######"; X# ^ (1 / I%)
|
||||
NEXT I%
|
||||
END
|
||||
|
||||
FUNCTION NthRoot# (N%, X#, Precision#)
|
||||
' Returns the Nth root of value X to stated Precision
|
||||
X0# = X#
|
||||
X1# = X# / N% ' initial guess
|
||||
DO WHILE ABS(X1# - X0#) > Precision#
|
||||
X0# = X1#
|
||||
X1# = ((N% - 1) * X1# + X# / X1# ^ (N% - 1)) / N%
|
||||
LOOP
|
||||
NthRoot# = X1#
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue