Skip to content

Instantly share code, notes, and snippets.

/HW5

Created October 19, 2012 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3915963 to your computer and use it in GitHub Desktop.
Save anonymous/3915963 to your computer and use it in GitHub Desktop.
Perfect Number
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main ()
{
int startVal, endVal, sum = 0;
cout << "Enter starting integer: ";
cin >> startVal;
cout << "Enter ending integer: ";
cin >> endVal;
for (int i = startVal; i <= endVal; i++)
{
for (int j = 1; j <= i/2; j++)
{
if(i % j == 0)
sum = sum + j;
}
}
system("PAUSE");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment