Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/Nth-root/Craft-Basic/nth-root.basic
Normal file
36
Task/Nth-root/Craft-Basic/nth-root.basic
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
precision 6
|
||||
|
||||
let a = int(rnd * 5999) + 2
|
||||
|
||||
print "calculating nth root of ", a, "..."
|
||||
|
||||
for n = 1 to 10
|
||||
|
||||
gosub nroot
|
||||
print n, " : ", y
|
||||
|
||||
next n
|
||||
|
||||
end
|
||||
|
||||
sub nroot
|
||||
|
||||
let p = .00001
|
||||
|
||||
let x = a
|
||||
let y = a / n
|
||||
|
||||
do
|
||||
|
||||
if abs(x - y) > p then
|
||||
|
||||
let x = y
|
||||
let y = ((n - 1) * y + a / y ^ (n - 1)) / n
|
||||
|
||||
endif
|
||||
|
||||
wait
|
||||
|
||||
loop abs(x - y) > p
|
||||
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue