Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Nth-root/BASIC256/nth-root.basic
Normal file
24
Task/Nth-root/BASIC256/nth-root.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
function nth_root(n, a)
|
||||
precision = 0.0001
|
||||
|
||||
dim x(2)
|
||||
x[0] = a
|
||||
x[1] = a /n
|
||||
while abs(x[1] - x[0]) > precision
|
||||
x[0] = x[1]
|
||||
x[1] = ((n -1.0) * x[1] +a / x[1]^(n -1.0)) / n
|
||||
end while
|
||||
return x[1]
|
||||
end function
|
||||
|
||||
print " n 5643 ^ 1 / n nth_root ^ n"
|
||||
print " --------------------------------------"
|
||||
for n = 3 to 11 step 2
|
||||
tmp = nth_root(n, 5643)
|
||||
print " "; n; " "; tmp; chr(9); (tmp ^ n)
|
||||
next n
|
||||
print
|
||||
for n = 25 to 125 step 25
|
||||
tmp = nth_root(n, 5643)
|
||||
print n; " "; tmp; chr(9); (tmp ^ n)
|
||||
next n
|
||||
Loading…
Add table
Add a link
Reference in a new issue