Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/Nth-root/BBC-BASIC/nth-root.basic
Normal file
13
Task/Nth-root/BBC-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
*FLOAT 64
|
||||
@% = &D0D
|
||||
PRINT "Cube root of 5 is "; FNroot(3, 5, 0)
|
||||
PRINT "125th root of 5643 is "; FNroot(125, 5643, 0)
|
||||
END
|
||||
|
||||
DEF FNroot(n%, a, d)
|
||||
LOCAL x0, x1 : x0 = a / n% : REM Initial guess
|
||||
REPEAT
|
||||
x1 = ((n% - 1)*x0 + a/x0^(n%-1)) / n%
|
||||
SWAP x0, x1
|
||||
UNTIL ABS (x0 - x1) <= d
|
||||
= x0
|
||||
Loading…
Add table
Add a link
Reference in a new issue