Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
23
Task/Nth-root/AppleScript/nth-root.applescript
Normal file
23
Task/Nth-root/AppleScript/nth-root.applescript
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
set outPutString to ""
|
||||
set outPutString to outPutString & nthRoot2(34, 5) & linefeed
|
||||
set outPutString to outPutString & nthRoot2(42, 10) & linefeed
|
||||
set outPutString to outPutString & nthRoot2(5, 2) & linefeed
|
||||
|
||||
on nthRoot(x, n)
|
||||
local n1, y, res, abs
|
||||
set n1 to n - 1
|
||||
set res to x / n
|
||||
set abs to x
|
||||
repeat until abs < 1.0E-14
|
||||
set y to res
|
||||
set res to ((n1 * y) + (x / (y ^ n1))) / n
|
||||
if res > y then
|
||||
set abs to res - y
|
||||
else
|
||||
set abs to y - res
|
||||
end if
|
||||
end repeat
|
||||
set y to res div 1
|
||||
if res = y then return y
|
||||
return res
|
||||
end nthRoot
|
||||
Loading…
Add table
Add a link
Reference in a new issue