/*

  Perfect Numbers by Kenneth L Moore:

  The first thing I did was to research perfect numbers.

  I found that the first several perfect numbers consist of:

   6, 
   28, 
   496, 
   8128, 
   33550336, 
   8589869056, 
   137438691328, 
   2305843008139952128,
   2658455991569831744654692615953842176,
   191561942608236107294793378084303638130997321548169216,

  Since I am limiting my program to 1x10^6, I put the first 5 
  numbers into an array.

  This is the most efficient solution to the problem.

  My program will easily find the numbers up to 1,000,000 with
  extraordinary efficiency. You should almost never compute cpu 
  intensive numbers that can be put into a look up table.

  Note: this program was compiled in MSVC++

*/

#include <iostream>
using namespace std;

// make const because these values should never be modified.
const unsigned int perfect[5] = {6,28,496,8128,33550336};

void main(void)
{
    int const MAX = 1000000;
    cout << "Perfect numbers up to " << MAX << "\n";
    int i = 0;
    while(perfect[i]<MAX && i<5){
       cout << perfect[i] << endl;
       i++;
    }
    cout << " Enter anything to terminate \n";
    cin>>i;// make dos window visible until user enters something.
}