Why do I get the error "Floating point exception"?
<p>I am trying to write a code that finds perfect numbers lower than the user's input.
Sample of correct output:</p>

<blockquote>
  <p>Enter a positive integer: 100<br>
  6 is a perfect number<br>
  28 is a perfect number<br>
  There are no more perfect numbers less than or equal to 100  </p>
</blockquote>

<p>But when I run my code, I get the error <code>Floating point exception</code></p>

<p>and can not figure out why. What am I doing wrong?</p>

<p>Here is my code:</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

bool isAFactor(int, int);

int main(){
    int x, y;
    int countOut, countIn;
    int userIn;
    int perfect = 0;

    cout &lt;&lt; "Enter a positive integer: ";
    cin &gt;&gt; userIn;

    for(countOut = 0; countOut &lt; userIn; countOut++){
        for(countIn = 1; countIn &lt;= countOut; countIn++){
            if(isAFactor(countOut, countIn) == true){
                countOut = countOut + perfect;
            }
        }

        if(perfect == countOut){
            cout &lt;&lt; perfect &lt;&lt; " is a perfect number" &lt;&lt; endl;
        }

        perfect++;
    }

    cout &lt;&lt; "There are no more perfect numbers less than or equal to " &lt;&lt; userIn &lt;&lt; endl;

    return 0;
}


bool isAFactor(int inner, int outer){
    if(outer % inner == 0){
        return true;
    }

    else{
        return false;
    }
}
</code></pre>
