Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Nth-root/Tcl/nth-root-1.tcl
Normal file
3
Task/Nth-root/Tcl/nth-root-1.tcl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
proc nthroot {n A} {
|
||||
expr {pow($A, 1.0/$n)}
|
||||
}
|
||||
11
Task/Nth-root/Tcl/nth-root-2.tcl
Normal file
11
Task/Nth-root/Tcl/nth-root-2.tcl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
proc nthroot {n A} {
|
||||
set x0 [expr {$A / double($n)}]
|
||||
set m [expr {$n - 1.0}]
|
||||
while 1 {
|
||||
set x1 [expr {($m*$x0 + $A/$x0**$m) / $n}]
|
||||
if {abs($x1 - $x0) < abs($x0 * 1e-9)} {
|
||||
return $x1
|
||||
}
|
||||
set x0 $x1
|
||||
}
|
||||
}
|
||||
5
Task/Nth-root/Tcl/nth-root-3.tcl
Normal file
5
Task/Nth-root/Tcl/nth-root-3.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
puts [nthroot 2 2]
|
||||
puts [nthroot 5 34]
|
||||
puts [nthroot 5 [expr {34**5}]]
|
||||
puts [nthroot 10 [expr 7131.5**10]]
|
||||
puts [nthroot 0.5 7]; # Squaring!
|
||||
Loading…
Add table
Add a link
Reference in a new issue