title: Find a number that occurs twice in an array
body: <p>I have to write a program where the user enters a number <em>n</em>, and then enters <em>n</em>+1 numbers in the range [1, n], where exactly one of those numbers occurs more than once. The program returns the number that occurs more than once.</p>
  
  <p>So, for example, if the input is like this:</p>
  
  <pre><code>3
  1
  2
  3
  2
  </code></pre>
  
  <p>then <em>n</em>&nbsp;=&nbsp;3, the rest of the input is four numbers in the range [1,3], and the output is <code>2</code> (since that's the number that occurs more than once).</p>
  
  <p>I am not allowed to use vectors.</p>
  
  <p>I thought I could do it this way:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      int i,n,nr,x,num,aux,k;
      scanf("%d", &amp;n);
      nr = 0;
      for (i=0; i &lt; n+1; i++)
      {
          scanf("%d", &amp;num);
          nr = nr * 10 + num; 
      }
      k=1;
      while(k!=2){
          aux=nr%10;
          nr=nr/10;
          x=nr;
          while (x&gt;0){
              x=x/2;
              if (aux==x%10){
                  printf("Numarul este %d", aux);
                  k=2;
                  break;
              }
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>but this only works for one-digit numbers, because I'm multiplying by 10. If I want to support larger numbers, I could multiply by something bigger, but then <code>nr</code> gets too big.</p>
  
  <p>So: how can I support numbers greater than 10?</p>