Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
23
Task/Nth-root/ANSI-BASIC/nth-root.basic
Normal file
23
Task/Nth-root/ANSI-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
100 REM Nth root
|
||||
110 DECLARE EXTERNAL FUNCTION NthRoot
|
||||
120 LET X = 144
|
||||
130 PRINT "Finding the nth root of"; X; "to 6 decimal places"
|
||||
140 PRINT " x n root x ^ (1 / n)"
|
||||
150 PRINT "--------------------------------------"
|
||||
160 FOR I = 1 TO 8
|
||||
170 PRINT USING "### ": X;
|
||||
180 PRINT USING "#### ": I;
|
||||
190 PRINT USING "###.######": NthRoot(I, X, 1.000000E-07);
|
||||
200 PRINT USING " ###.######": X ^ (1 / I)
|
||||
210 NEXT I
|
||||
220 END
|
||||
230 EXTERNAL FUNCTION NthRoot(N, X, Precision)
|
||||
240 REM Returns the Nth root of value X to stated Precision
|
||||
250 LET X0 = X
|
||||
260 LET X1 = X / N ! initial guess
|
||||
270 DO WHILE ABS(X1 - X0) > Precision
|
||||
280 LET X0 = X1
|
||||
290 LET X1 = ((N - 1) * X1 + X / X1 ^ (N - 1)) / N
|
||||
300 LOOP
|
||||
310 LET NthRoot = X1
|
||||
320 END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue