title: Getting the error floating point exception: 8
body: <p>I have no idea why g++ doesn't like my code. It ran fine in java. Any insights would be greatly appreciated.</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  bool isPrime(long number);
  
  int main(){
  const long number = 600851475143;
  long max = 0;
  for(long i= 0; i*i &lt;= number; i++)
      if(number % i == 0 &amp;&amp; isPrime(i))
          max = i;
  cout&lt;&lt; max &lt;&lt; endl;
  
  return 0;
  }
  
  bool isPrime(long number){
  if(number &lt;= 1) return false;
  if(number == 2) return true;
  if(number % 2 == 0) return false;
  
  for(long     i= 3; i*i &lt;= number; i+=2)
      if(number % i == 0)
          return false;
  return true;
  }
  </code></pre>