title: Reads an integer and print all perfect number smaller than given integer
body: <p>I can find perfect numbers but I can't print all perfect numbers smaller than a given integer.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int main() {
  
      cout &lt;&lt; "Enter a number ";
      int number{};
      cin &gt;&gt; number;
      int sum{};
  
      int j{};
      for (int i = 1; i &lt; number ; i++) {
          j = number % i;
          if (j == 0)
              sum = sum + i;
      }
      if (sum == number){
          cout &lt;&lt; sum;
  </code></pre>
  
  <p>I expect the output <code>6 28 496</code> for <code>input=500</code></p>