// Ashton Pearson, 558771747
//
// This program reads an integer and determines whether
// or not it is a perfect integer.

#include <iostream>
using namespace std;

int main()
{
    int x;
    int iCount = 1;
    int sum = 0;

    cout << "Enter an integer to test (< 2 to exit): ";
    cin >> x;


    while (x >= 2 )
    {
        cout << "Testing " << x << "..." << endl;

        while (iCount <= (x/2))
        {
            if (x % iCount == 0)
            {
                sum = sum + iCount;
                iCount = iCount + 1;
            }
            else 
            {
                iCount = iCount + 1;
            }
        }
        if (x == sum)
        {
            cout << x << " is perfect\n";
        }
        else
        {
            cout << x << " is NOT perfect\n";
        }
            cout << "\nEnter an integer to test (< 2 to exit): ";
            cin >> x;
    }

    return 0;
}

Everything works fine. 6 says perfect (which is good), BUT it says 28 is NOT a perfect number but it is!!! help plz!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.