tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
19
Task/Nth-root/PureBasic/nth-root.purebasic
Normal file
19
Task/Nth-root/PureBasic/nth-root.purebasic
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#Def_p=0.001
|
||||
|
||||
Procedure.d Nth_root(n.i, A.d, p.d=#Def_p)
|
||||
Protected Dim x.d(1)
|
||||
x(0)=A: x(1)=A/n
|
||||
While Abs(x(1)-x(0))>p
|
||||
x(0)=x(1)
|
||||
x(1)=((n-1.0)*x(1)+A/Pow(x(1),n-1.0))/n
|
||||
Wend
|
||||
ProcedureReturn x(1)
|
||||
EndProcedure
|
||||
|
||||
;//////////////////////////////
|
||||
Debug "125'th root of 5642 is"
|
||||
Debug Pow(5642,1/125)
|
||||
Debug "First estimate is:"
|
||||
Debug Nth_root(125,5642)
|
||||
Debug "And better:"
|
||||
Debug Nth_root(125,5642,0.00001)
|
||||
Loading…
Add table
Add a link
Reference in a new issue