I am trying to develop this code in C++ where the user inputs an integer, such as 10. And the program finds all the divisors between 1 and the number the user inputed such as 10.

The program will output the answer to the user in a fashion like this:

list of divisors of the integer between 1 and 10:

>divisors of 1: 1

>divisors of 2: 1, 2

>divisors of 3: 1, 3

>divisors of 4: 1, 2, 4

>divisors of 5: 1, 5

and so on.

I have started to write a code for this, and I think I have done a decent job laying out the easy outline part. I just need some help developing an algorithm for it.

What I have so far is below, any advice is greatly appreciated.

int main() { //Declare Varibles int val,count,div //Get input from user cout >> "Please enter the maximum integer value you wish to find divisors:">>endl; cin >> val; //Execute commands count = 1; cout>> "List of divisors of the the integer between 1 and ">>val>>endl; while(count=<val) { count%count = div; cout>>"divisors of ">>count>>":">>div>>endl; count++; }

Thank you in advance

This post has been edited by **NickDMax**: 05 February 2010 - 07:39 AM

Reason for edit:: Added/Fixed code tags [code]...your program here...[/code]