I just looked at this for 30 seconds, do you just XOR everything together? Then you could XOR it with all the numbers 1 to n again to get just the duplicate number, as every number would appear in the XOR twice except the duplicate number which would appear once.
Edit: I misread the problem :D I initially read it as every number appears once and one number appears twice, but alas it's not so simple :D