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/AutoHotkey/nth-root.ahk
Normal file
19
Task/Nth-root/AutoHotkey/nth-root.ahk
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
p := 0.000001
|
||||
|
||||
MsgBox, % nthRoot( 10, 7131.5**10, p) "`n"
|
||||
. nthRoot( 5, 34.0 , p) "`n"
|
||||
. nthRoot( 2, 2 , p) "`n"
|
||||
. nthRoot(0.5, 7 , p) "`n"
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
nthRoot(n, A, p) { ; http://en.wikipedia.org/wiki/Nth_root_algorithm
|
||||
;---------------------------------------------------------------------------
|
||||
x1 := A
|
||||
x2 := A / n
|
||||
While Abs(x1 - x2) > p {
|
||||
x1 := x2
|
||||
x2 := ((n-1)*x2+A/x2**(n-1))/n
|
||||
}
|
||||
Return, x2
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue