Subj : Re: puzzle To : comp.programming From : cri Date : Mon Jul 11 2005 05:15 am On Sun, 10 Jul 2005 21:35:01 GMT, cri@tiac.net (Richard Harter) wrote: >Method 2: Determine the sum of the numbers 0...n, then the sum of the >sequence. The difference of the two sums is the missing number. To >avoid overflow/underflow do the sums module n+1. A prettier way to do this is to compute sum(i -a[i]) for i=1...n Alternatively subtract sum(a[i]) from n*(n+1)/2. Richard Harter, cri@tiac.net http://home.tiac.net/~cri, http://www.varinoma.com Save the Earth now!! It's the only planet with chocolate. .