title: Can you check for duplicates by taking the sum of the array and then the product of the array?
body: <p>Let's say we have an array of size N with values from 1 to N inside it. We want to check if this array has any duplicates. My friend suggested two ways that I showed him were wrong:</p>
  <ol>
  <li><p>Take the sum of the array and check it against the sum 1+2+3+...+N. I gave the example 1,1,4,4 which proves that this way is wrong since 1+1+4+4 = 1+2+3+4 despite there being duplicates in the array.</p>
  </li>
  <li><p>Next he suggested the same thing but with multiplication. i.e. check if the product of the elements in the array is equal to N!, but again this fails with an array like 2,2,3,2, where 2x2x3x2 = 1x2x3x4.</p>
  </li>
  </ol>
  <p>Finally, he suggested doing both checks, and if one of them fails, then there is a duplicate in the array. I can't help but feel that this is still incorrect, but I can't prove it to him by giving him an example of an array with duplicates that passes both checks. I understand that the burden of proof lies with him, not me, but I can't help but want to find an example where this doesn't work.</p>
  <p>P.S. I understand there are many more efficient ways to solve such a problem, but we are trying to discuss this particular approach.</p>
  <p>Is there a way to prove that doing both checks doesn't necessarily mean there are no duplicates?</p>