Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Nth-root/Liberty-BASIC/nth-root.basic
Normal file
21
Task/Nth-root/Liberty-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
print "First estimate is: ", using( "#.###############", NthRoot( 125, 5642, 0.001 ));
|
||||
print " ... and better is: ", using( "#.###############", NthRoot( 125, 5642, 0.00001))
|
||||
print "125'th root of 5642 by LB's exponentiation operator is "; using( "#.###############", 5642^(1 /125))
|
||||
|
||||
print "27^(1 / 3)", using( "#.###############", NthRoot( 3, 27, 0.00001))
|
||||
print "2^(1 / 2)", using( "#.###############", NthRoot( 2, 2, 0.00001))
|
||||
print "1024^(1 /10)", using( "#.###############", NthRoot( 10, 1024, 0.00001))
|
||||
|
||||
wait
|
||||
|
||||
function NthRoot( n, A, p)
|
||||
x( 0) =A
|
||||
x( 1) =A /n
|
||||
while abs( x( 1) -x( 0)) >p
|
||||
x( 0) =x( 1)
|
||||
x( 1) =( ( n -1.0) *x( 1) +A /x( 1)^( n -1.0)) /n
|
||||
wend
|
||||
NthRoot =x( 1)
|
||||
end function
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue