title: Adding to vectors correctly
body: <p>I'm creating a program that puts prime numbers into a vector. I'll give an example to better demonstrate how this program should work:</p>
  
  <p><strong>User: 3</strong></p>
  
  <p><strong>Output 3</strong></p>
  
  <p><strong>User: 13</strong></p>
  
  <p><strong>Ouput: 3 5 7 11 13</strong></p>
  
  <p>To put it in words, this program is adding up the prime numbers less than or equal to the input of the user. Then finally giving a bool of true or false if the actual input of the user was a prime number.</p>
  
  <pre><code>            if (found)
              {
                  vector_output.push_back(j);
  
              }
              if (number == j)
              {
                  if (found ==false)
                      return false;
                  else
  
  
  
  
  void checkprime::vector_finder()    
  {
      for (int k=0; k &lt; vector_output.size(); k ++)
      {    
          cout &lt;&lt; vector_output[k];
      }    
  }
  </code></pre>
  
  <p>Unfortunately, my output is:</p>
  
  <p><strong>User 3</strong></p>
  
  <p><strong>Output 3</strong></p>
  
  <p><strong>User 13</strong></p>
  
  <p><strong>Output: 3 5 5 5 7 7 7 7 7 9 11 13</strong></p>
  
  <p>How can I get it to where the vector does not duplicate numbers?</p>
  
  <p>I thought something like an if statement right before the vector_output.pushback(j) such as</p>
  
  <pre><code>if (vector_output.size() != 0 &amp;&amp; vector.output.back() != j)
        vector_output.push_back(j);
  </code></pre>
  
  <p>would work, but it's not outputting anything with this.</p>