tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
16
Task/Nth-root/Sather/nth-root-1.sa
Normal file
16
Task/Nth-root/Sather/nth-root-1.sa
Normal 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;
|
||||
6
Task/Nth-root/Sather/nth-root-2.sa
Normal file
6
Task/Nth-root/Sather/nth-root-2.sa
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class MAIN is
|
||||
main is
|
||||
a:FLT := 2.5 ^ 10.0;
|
||||
#OUT + MATH::nthroot(10, a) + "\n";
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue