# Last question on factors!

All i need this to do now is to print out all the factors of the highest number and not include the highest number itself.

Been messing for a while but can't seem to quite get it right.

Any help would be appreciated

Thank you...

Here is my code

#include
int main(void)
{
int x,y,count=0,i,n;
for (x=2;x<=1000;++x)
{
i=0;
for (y=2;y<=1000;++y)
if (!(x%y)) ++i;
if (i>count) {n=x;count=i;}
}
printf("The integer %d has the most number of factors <=1000

",n);
printf("There are %d factors

",count);
printf("They are.................

");
return 0;

• (pseudo code- try it yourself!!!)
I would say,
always save the last factor in a variable,
and if you found one thats higher, print it.

int curHighest = 0;

(Where do you print found factors)
There you can the do something like this:
if(curHighest > 0 && curHighest <= x%y)
{
printit("last %d", curHighest);
curHighest = x%y;
}

Then it wouldnt be printed the last time
youre passing...
There may be other ways to solve this program.