home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 1
/
crawlyvol1.bin
/
program
/
compiler
/
vici_102
/
examples
/
sqrt.e
< prev
next >
Wrap
Text File
|
1993-01-12
|
467b
|
28 lines
class SQRT
feature
create is
do
io.putstring("Integer-Wurzel berechnen von: ");
io.readint;
io.putstring("Die Wurzel aus ");
io.putint(io.lastint);
io.putstring(" ist ");
io.putint(sqrt(io.lastint));
io.new_line;
end;
sqrt(n: integer): integer is
require n >= 0
do
from
invariant Result^2 <= n
until (Result+1)^2 > n
loop
Result := Result + 1
end;
ensure Result^2 <= n and (Result+1)^2 > n
end;
end