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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.