I took these notes in class, and mangled them somehow. For the life of me, I can't figure out where the error is. It's meant to find perfect numbers. A perfect number is a number that is the sum of its divisors (minus itself). Thanks for taking a look- I really appreciate it.
#include <iostream>
usingnamespace std;
int main()
{
int n,k;
int sum;
for(n=2;n<=10000;n++) //we're trying to see if n is perfect.
{
sum=0;
for(k=n/2;k<=n/2;k++) //if k<=n/2 and sum <=n
//also k should start at large end, not low.
{
if(n%k==0)
sum=sum+k;
if(sum==n)
cout << n << " is perfect!" << endl;
}
}
return 0;
}