Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Nth-root/Objeck/nth-root.objeck
Normal file
18
Task/Nth-root/Objeck/nth-root.objeck
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class NthRoot {
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
NthRoot(5, 34, .001)->PrintLine();
|
||||
}
|
||||
|
||||
function : NthRoot(n : Int, A: Float, p : Float) ~ Float {
|
||||
x := Float->New[2];
|
||||
x[0] := A;
|
||||
x[1] := A / n;
|
||||
|
||||
while((x[1] - x[0])->Abs() > p) {
|
||||
x[0] := x[1];
|
||||
x[1] := ((n - 1.0) * x[1] + A / x[1]->Power(n - 1.0)) / n;
|
||||
};
|
||||
|
||||
return x[1];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue