title: Runtime error, makes my .exe crash and I am not sure why
body: <p>I can take a guess that it has something to do with working with the unsigned long long int.</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  typedef unsigned long long int uint64;
  
  int main(int argc, char *argv[])
  {
  
  
  
      uint64 number_in_question = 600851475143LL;
  
      long double sqrt_in_question = sqrt(number_in_question);
      bool primes_array[number_in_question+1];
  
  
  
      for (uint64 i = 0; i &lt;= number_in_question; i++) {
          primes_array[i] = true;
      }
  
      for (uint64 i = 2; i &lt;= sqrt_in_question; i++) {
          if(primes_array[i] == true) {
              // for every multiple of this prime, mark it as not prime
              for (uint64 ii = i*2; ii &lt;= number_in_question; ii += i) {
                  primes_array[ii] = false;           
              }
          }
      }   
  
      for (uint64 i = 0; i &lt;= number_in_question; i++) {
          if(primes_array[i] == true)
          cout &lt;&lt; i &lt;&lt; ", ";
      }
  
  
      system("PAUSE");
  
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>Edit1:
  Some background of what I am trying to do:</p>
  
  <p>I am trying to mimic this technique: <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="nofollow">http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes</a>
  while I am using an array to store a simple "is it prime" 1 for yes, 0 for no. The end goal is to solve this:</p>
  
  <p><code>What is the largest prime factor of the number 600851475143 ?</code> Listed here: <a href="http://projecteuler.net/problem=3" rel="nofollow">http://projecteuler.net/problem=3</a>.  I am just working on the primes and then will work on the prime factors.</p>
  
  <p>Edit2:</p>
  
  <p>Upon looking at the Wikipedia link I posted, I realized they have puesdocode (skipped over that and came up with what I have) and realized that had this note: 
  Large ranges may not fit entirely in memory. In these cases it is necessary to use a segmented sieve where only portions of the range are sieved at a time.[14] For ranges so large that the sieving primes could not be held in memory, space-efficient sieves like that of Sorenson are used instead.
  Therefore I will have to think of a way to do this using a "segmented sieve" method.</p>
  
  <p>Edit3:</p>
  
  <p>Changed the array to account for the [0] element so the "issue" is only focused on the array memory size being too large for future references; also stored the array as a bool instead of a uint64.</p>