C++ Problems

Problem solved.
Last edited on
I would read in each number into an array or vector, until the end of the data set. Do you know how to do that with fstream? I take it you covered it in class if you are asked to do it for homework? Are you familiar with arrays or vectors?

Then I would look at the data set. Only 1 is a positive integer that has no proper divisors, so first of all if n == 1, then output "none", otherwise, you need to enter a loop.
for(i = 1;i < n; ++n)
    if(n % i == 0)
        sum = sum + i; //Sum will become the total of the proper divisors of n. 

Something like that. This loop can be optimized, but get it working first of all.
Last edited on
Sir Mats

We have been introduced to arrays. We still haven't discussed vectors. I'm really having a hard time with reading and writing files. Thanks for your reply by the way. :) Gladly appreciated.
Last edited on
Topic archived. No new replies allowed.