Factors of a number - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Factors of a number

Hey...

i have managed to create this short piece of code to enter a number and find its factors but i'm struggling to write the finishing program to find the number that is less than 1000 which has the most factors and print the factors without 1 and itself.

I know the number is 840 but not sure how to finish this off.

Can somebody help me please?

Thanx.....anton

#include
#include
long int x;
long int y=1;
main ()


{
printf("Enter value : ");
scanf("%d", &x);
printf("{");
for(y=1;y<x;y++)
if(x%y==0)
printf("%d, ", y);
printf("%d}
", x);
return 0;
}

Comments

  • DonotaloDonotalo Posts: 715Member
    : Hey...
    :
    : i have managed to create this short piece of code to enter a number and find its factors but i'm struggling to write the finishing program to find the number that is less than 1000 which has the most factors and print the factors without 1 and itself.
    :
    : I know the number is 840 but not sure how to finish this off.
    :
    : Can somebody help me please?
    :
    : Thanx.....anton[code]
    :
    : #include
    : #include
    : long int x;
    : long int y=1;
    : main ()
    :
    :
    : {
    : printf("Enter value : ");
    : scanf("%d", &x);
    : printf("{");
    : for(y=1;y max_fac)
    /* some code here */
    }
    [/code]
    [/purple]
    [hr][purple]~Donotalo()[/purple]

Sign In or Register to comment.