Factors Program

 

Overview:  In this program, the user will supply a positive integer greater than 1.  The program will list all factors and count the number of factors.  Finally, the program will display whether or not the number is prime.

 

Specifics:

 

Use data validation to ensure that the user enters a positive number greater than 1 to factor.  Data validation involves putting the prompt and input statement into a loop until the data is valid.

 

After the user has entered valid data, show all factors of that number.  A factor is a number that divides evenly into that number.  (Focus on the phrase divides evenly.  What does this mean?  How can your computer know if it divides evenly?)

 

In addition to showing factors, use a counter to count the number of factors. 

 

At the end of the program, show a message that says either “Prime Number” or “Not Prime.”

 

Sample I/O:

 

Enter a number greater than 1 to factor:   24

Thank you – Factors of 24 include:

1, 2, 3, 4, 6, 8, 12, 24.

There are 8 total factors – Not Prime.

 

When complete, put the entire program into a loop to test if the user would like to factor another number using Y/N interaction. 

 

Save the project, source code, and exe files as factors in your submit folder.