repo.or.cz
/
why3.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Merge branch 'search-in-a-two-dimensional-grid' into 'master'
[why3.git]
/
examples
/
micro-c
/
isqrt.c
blob
0ae2562b7c214614fe4befea57c931a6f957727f
1
2
int
isqrt
(
int
n
)
3
//@ requires n >= 0;
4
//@ ensures result * result <= n < (result + 1) * (result + 1);
5
{
int
r
=
0
;
6
int
s
=
1
;
7
while
(
s
<=
n
) {
8
//@ invariant 0 <= r;
9
//@ invariant r * r <= n;
10
//@ invariant s == (r+1) * (r+1);
11
//@ variant n - s;
12
r
++;
13
s
+=
2
*
r
+
1
;
14
}
15
return
r
;
16
}