// ----------------------------------------------------------------------------- // The following program computes the sum of the first n // natural numbers (which is n*(n+1)/2) // ----------------------------------------------------------------------------- function sumUp(nat n) : nat { nat i,sum; i = 1; sum = 0; while(i <= n) { sum = sum + i; i = i + 1; } return sum; } thread SumUp { nat sum; sum = sumUp(10); }