4 // la somme des n premiers entiers
8 //@ ensures result == n * (n + 1) / 2;
11 for (int k
= 0; k
<= n
; k
++) {
12 //@ invariant k <= n + 1;
13 //@ invariant s == (k - 1) * k / 2;
20 int triangular2(int n
)
22 @ ensures result == n * (n + 1) / 2;
26 return n
+ triangular2(n
- 1);
30 printf("somme 1 + .. + 100 = %d\n", triangular(100));
31 printf("somme 1 + .. + 100 = %d\n", triangular2(100));