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 @@
class MATH is
nthroot(n:INT, a:FLT):FLT
pre n > 0
is
x0 ::= a / n.flt;
m ::= n - 1;
loop
x1 ::= (m.flt * x0 + a/(x0^(m.flt))) / n.flt;
if (x1 - x0).abs < (x0 * 1.0e-9).abs then
return x1;
end;
x0 := x1;
end;
end;
end;

View file

@ -0,0 +1,6 @@
class MAIN is
main is
a:FLT := 2.5 ^ 10.0;
#OUT + MATH::nthroot(10, a) + "\n";
end;
end;