Debian Codegraph @

benchmarks.larceny/src/sum.java

raw
1 /* SUM -- Compute sum of integers from 0 to 10000 */
2
3 class sum {
4
5 static int run ()
6 {
7 int i = 10000;
8 int n = 0;
9
10 while (i >= 0)
11 {
12 n = n+i;
13 i = i-1;
14 }
15
16 return n;
17 }
18
19 public static void main (String args[])
20 {
21 int i;
22 int result = 0;
23
24 for (i=0; i<10000; i++)
25 result = run ();
26
27 if (result != 50005000)
28 System.out.println ("*** wrong result ***");
29 }
30 }
31