Home > Back-end >  New one, how do you write this program
New one, how do you write this program

Time:09-29

Level task: write a program that if a number is equal to the sum of its factors, this number is called "the number", such as 6=1 + 2 + 3, programming to find the number number within a specified range,

CodePudding user response:

I am absolutely won't help you write your homework!

In addition, if you really want to find a ready-made, can go to the online search for the keyword, or combined with C language, must complete code can be found

CodePudding user response:

#include

Int main ()

{

Int I, j, n.

The scanf (" % d ", & amp; N)
for(i=1; i<=n; I++)

{

int sum=0;

For (j=1; j
{

If (I % j==0) sum +=j;

}

If (sum==I) printf (" % d \ n ", I);

}

return 0;

}
There may be a wrong, I don't have the test, I didn't write carefree get boring
  • Related