mardi 8 décembre 2015

How to display all abundant numbers less than a given number

I am having trouble with translating my algorithm into c++ code that will display all abundant numbers less than the inputted number. I want to create a program that will display all abundant numbers less than an inputted number. For example if I entered a number like 19, the console should print out 12 and 18. The algorithm is this.

  1. Scan through each number
  2. Check whether its an abundant number
  3. If it is an abundant number, then print it out

I am using Microsoft Visual Studios 2013 IDE and a compiler that supports c++11.

This is the code I have so far

#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Enter a number" << endl;
cin >> number;
for (int i = 1; i < number; i++)
{
// Don't know what to put here
}
char inputCharacter;
cin >> inputCharacter;
return 0;
}

Aucun commentaire:

Enregistrer un commentaire