Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Nth-root/Phixmonti/nth-root.phixmonti
Normal file
27
Task/Nth-root/Phixmonti/nth-root.phixmonti
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
def nthroot
|
||||
var n var y
|
||||
1e-15 var eps /# relative accuracy #/
|
||||
1 var x
|
||||
true
|
||||
while
|
||||
y x n 1 - power / x - n / var d
|
||||
x d + var x
|
||||
eps x * var e /# absolute accuracy #/
|
||||
d 0 e - < d e > or
|
||||
endwhile
|
||||
x
|
||||
enddef
|
||||
|
||||
def printList
|
||||
len for get print endfor
|
||||
enddef
|
||||
|
||||
10 1024 3 27 2 2 125 5642 4 16 stklen tolist
|
||||
|
||||
len 1 swap 2 3 tolist
|
||||
for
|
||||
var i
|
||||
i get swap i 1 + get rot var e var b
|
||||
"The " e "th root of " b " is " b 1 e / power " (" b e nthroot ")" 9 tolist
|
||||
printList drop nl
|
||||
endfor
|
||||
Loading…
Add table
Add a link
Reference in a new issue