tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,16 @@
object NthRoot {
def main(args: Array[String]) {
println(nthroot(3, 32))
}
def nthroot1(n: Int, a: Double): Double = {
def loop(x0: Double) : Double = {
val x1 = (1.0d/n * ((n - 1) * x0 + a/math.pow(x0, n-1)))
if (x0 <= x1) x0
else loop(x1)
}
return loop(a/2)
}
}