title: "integer constant is too large for ‘long’ type" when finding largest prime factor
body: <p>I am working on solving Euler project 3:</p>
  
  <pre><code>Description: The prime factors of 13195 are 5, 7, 13 and 29.
               What is the largest prime factor of the number 600851475143 ?
  </code></pre>
  
  <p>This is my code to generate the answer.  However I need an integer type to hold <code>600851475143</code>.  When I compile this on GCC on a Mac I get:</p>
  
  <pre><code>integer constant is too large for ‘long’ type". 
  </code></pre>
  
  <p>I expect long long could easily hold this number.  I also tried making it unsigned. Why doesn't my code hold that small number and what can I do to make it work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  static bool IsPrimeFactor(int numToTest,int testNum,vector&lt;int&gt; factors)
  {
      if(numToTest%testNum==0) // is it a factor?
      {
          // see if it is a prime factor
          for(unsigned int i=0; i &lt; factors.size(); i++)
          {
              if(testNum%factors[i]==0)  // see if this factor
              {                          //is divisble by one we have already
  
                  return false;
              }
          }
  
          return true;
      }
      return false;
  }
  
  int main() {
      unsigned long long numToTest=600851475143;
      unsigned int testNum=2;  // 0 and 1 are assumed
      vector&lt;int&gt; factors;   
  
      while(testNum&lt;numToTest)   // don't go higher than the max num
      {
          if(IsPrimeFactor(numToTest,testNum,factors)) // is it a factor?
          {
              factors.push_back(testNum); // got through prime factors 
          }                                   // and none divided it
  
          testNum++;
      }
  
      for(unsigned int i=0; i &lt; factors.size(); i++)
      {
          cout &lt;&lt; "factor " &lt;&lt;factors[i] &lt;&lt; endl;
      }
  
      cout&lt;&lt;"Highest factor: " &lt;&lt; factors[factors.size()-1]&lt;&lt;endl;
  
      return 0;
  }
  </code></pre>