Stuck on a programming problem
Hi all just was looking for a bit of advise on a program assignment I
have and am stuck on. Not asking you to do the whole thing just am wondering how to go about writing the mathematical portion of the program. here it is
Find the difference between numbers with an odd number of factors and numbers with an even number of factors for all numbers greater than one and less than one million.
Your program must:
- use a conditional operator within a cout statement to determine whether to output the (odd factors) - (even factors) or(even factors) - (odd factors) so as to print to the console a positive difference between the two numbers,
- use a for loop that sequentially tests for factors starting at 1 and ending when the loop counter exceeds the number being considered.
- use output formatting to display the final output field seven characters wide,
- use a "const unsigned int" to store the parameter MAX_VALUE, which indicates the upper limit of numbers being considered,
- use increment and decrement operators when your algorithm's logic is incrementing or decrementing variables,
- use at most one while loop, one for loop, and one do-while loop
- output only the result using the specific format:
The difference between numbers with odd factors and numbers with even factors is xxxxxxx.<cr>
where "xxxxxxx" represents the seven-digit-wide output field for your answer, which must be a positive value as per item #4 above.
Thanks for any advise!