Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Nth-root/True-BASIC/nth-root.basic
Normal file
32
Task/Nth-root/True-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
FUNCTION Nroot (n, a)
|
||||
LET precision = .00001
|
||||
|
||||
LET x1 = a
|
||||
LET x2 = a / n
|
||||
DO WHILE ABS(x2 - x1) > precision
|
||||
LET x1 = x2
|
||||
LET x2 = ((n - 1) * x2 + a / x2 ^ (n - 1)) / n
|
||||
LOOP
|
||||
LET Nroot = x2
|
||||
END FUNCTION
|
||||
|
||||
PRINT " n 5643 ^ 1 / n nth_root ^ n"
|
||||
PRINT " ------------------------------------"
|
||||
FOR n = 3 TO 11 STEP 2
|
||||
LET tmp = Nroot(n, 5643)
|
||||
PRINT USING "####": n;
|
||||
PRINT " ";
|
||||
PRINT USING "###.########": tmp;
|
||||
PRINT " ";
|
||||
PRINT USING "####.########": (tmp ^ n)
|
||||
NEXT n
|
||||
PRINT
|
||||
FOR n = 25 TO 125 STEP 25
|
||||
LET tmp = Nroot(n, 5643)
|
||||
PRINT USING "####": n;
|
||||
PRINT " ";
|
||||
PRINT USING "###.########": tmp;
|
||||
PRINT " ";
|
||||
PRINT USING "####.########": (tmp ^ n)
|
||||
NEXT n
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue