Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Nth-root/Run-BASIC/nth-root.basic
Normal file
21
Task/Nth-root/Run-BASIC/nth-root.basic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
print "Root 125th Root of 5643 Precision .001 ";using( "#.###############", NthRoot( 125, 5642, 0.001 ))
|
||||
print "125th Root of 5643 Precision .001 ";using( "#.###############", NthRoot( 125, 5642, 0.001 ))
|
||||
print "125th Root of 5643 Precision .00001 ";using( "#.###############", NthRoot( 125, 5642, 0.00001))
|
||||
print " 3rd Root of 27 Precision .00001 ";using( "#.###############", NthRoot( 3, 27, 0.00001))
|
||||
print " 2nd Root of 2 Precision .00001 ";using( "#.###############", NthRoot( 2, 2, 0.00001))
|
||||
print " 10th Root of 1024 Precision .00001 ";using( "#.###############", NthRoot( 10, 1024, 0.00001))
|
||||
|
||||
wait
|
||||
|
||||
function NthRoot( root, A, precision)
|
||||
x0 = A
|
||||
x1 = A /root
|
||||
while abs( x1 -x0) >precision
|
||||
x0 = x1
|
||||
x1 = x1 / 1.0 ' force float
|
||||
x1 = (( root -1.0) *x1 +A /x1^( root -1.0)) /root
|
||||
wend
|
||||
NthRoot =x1
|
||||
end function
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue