Re: find a number



CBFalconer:

s = 0; i = 0;
do {
s -= i;
s += a[i++];
} while (i <= 1001);

minor optim.:

s = 0; i = 1(0);
while (i<1002(1001)) s+=a[i++];
s-=500500; (or (1000+1)*1000/2 - Gauss ;P, but precalculated is better)

printf("duplicate is %d\n", s);


--
Sc0rpi0
I hated going to weddings.
All the grandmas would poke me saying "You're next".
They stopped that when I started doing it to them at funerals.
.