title: Trying to print first 5 perfect numbers using Euler's theorem
body: <p>Euler theorem states that this equation results into a perfect number if the right side (2^n -1) is a prime number. </p>
  
  <p>2^(n-1) * (2^n -1)</p>
  
  <p>My code is trying to generate the first 5 perfect numbers being : 6,28,496.8128 etc... However upon execution it simply prints the numbers of Euler's equation with different n values (1,2,3,4 etc..). It seems there is a mistake with my Prime condition. Can anyone help ? </p>
  
  <p>So i get 6,28,120,496,2016 etc... as my result </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  int main(void) {
      for (int i = 2; i&lt;100; i++)
      {
      bool prime = true;
      for (int j = 2; j*j &lt;= i; j++)
      {
          if (pow(2,i) - 1 % j == 0)
          {
              prime = false;
              }
      }
      if (prime = true)
      {
          cout &lt;&lt; pow(2, i - 1)*(pow(2, i) - 1) &lt;&lt; " ";
      }
  }
  return 0;
  }
  </code></pre>