title: My C++ prime number identifier and prime factor finder has a bug
body: <p>I'm a beginner to C++ and this website, so any dumb mistakes are out of ignorance. For practice, I'm trying to write a program that identifies a prime number and gives a composite's prime factors if the user requests. The prime IDer works, but the prime factors do not. When I type in twelve as my number, it gives me the factors 2 3 and 5, and 12's prime factors are 2 2 and 3. What am I messing up? Here is the code. Don't mind the weird spaces or names.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;cmath&gt;
  #include &lt;string&gt;
  
  //Printing factors help
  void print(std::vector&lt;int&gt; const&amp; factors)
  {
      for (int i = 0; i &lt; factors.size(); i++) {
          std::cout &lt;&lt; factors.at(i) &lt;&lt; ' ';
      }
  }
  
  
  int main() {
  
      //Restarting it
      std::string again;
      again = "Yes";
  
      //Actual loop
      while (again == "Yes") {
  
          //Variable/vectors
          std::string pfacts;
          double input = 0;
          double result = 0;
          double looper = 2;
          int looper2 = 2;
          int printed = 0;
          int printed2 = 0;
  
          std::vector&lt;int&gt; factors;
          std::vector&lt;int&gt; holders;
  
          //Asking for number
          std::cout &lt;&lt; "Please enter your number.\n";
          std::cin &gt;&gt; input;
          double holder = input;
  
          //Ratting out trolls
          if (input == 0) {
              std::cout &lt;&lt; "Your number is neither.\n";
              looper = 1000003;
          }
  
          if (input == 1) {
              std::cout &lt;&lt; "Your number is neither.\n";
              looper = 1000003;
          }
  
  
          //Prime/composite loop
          while (looper &lt; 1000002 and input != 1 and fmod(result, 1) == 0) {
              result = input / looper;
  
              //Finding composite
              if (fmod(result, 1) == 0 and printed == 0) {
                  std::cout &lt;&lt; "Your number is composite.\n";
                  printed = 1;
                  looper = 1000003;
              }
  
              //Finding prime
              else if (fmod(result, 1) != 0 and printed2 == 0) {
                  std::cout &lt;&lt; "Your number is prime.\n";
                  printed2 = 1;
              }
  
          }
  
          //Asking about factors
          if (printed == 1) {
              std::cout &lt;&lt; "Would you like to know it's prime factors? (Please type Yes or No exactly)\n";
              std::cin &gt;&gt; pfacts;
          }
  
          //Actually finding them
          if (pfacts == "Yes") {
              while (looper2 &lt; 1000002) {
  
                  if (holder / looper2 == 0) {
                      factors.push_back(holder);
                      looper2 = 1000003;
                  }
  
                  if (looper2 &lt; 1000002 and fmod  (fmod(holder, looper2),   1) == 0 and looper2 % 2 != 0 or looper2 / 2 == 1) {
                      factors.push_back(looper2);
                      holder = holder / looper2;
                  }
                  looper2 = looper2 + 1;
              }
  
              //Printing them
              print(factors);
              std::cout &lt;&lt; "\n";
  
  
          }
  
  
  
  
  
  
  
  
  
  
  
  
  
          //Again?
          std::cout &lt;&lt; "Do you need to input another number? (Please type, exactly: Yes or No)\n";
          std::cin &gt;&gt; again;
  
      }
  
  }
  </code></pre>