# Thread: How to find the proper divisor?

1. ## How to find the proper divisor?

The problems says "a program will find the sum of the proper divisors of a give number n. The proper divisors on n are the numbers less than n that divides it evenly, they do not include n itself." I have no idea for this program, which function should i use?

2. use modulo

Code:
```if ((x % y) == 0)
is divisor
else
ain't```

3. Just loop from Div = N - 1 to 1 and check if that N % Div is zero. If it is then print Div. Feel free to use my code as an example, but you aren't allowed to use it for any educational credits.
Code:
```/* (c) Copyright 2002 Daniel Raxter, All Rights Reserved. */
#include <stdio.h>
#include <stdlib.h>

void ListProperDivs (int N)
{
int Div = N;

while (--Div > 0){
if ((N % Div) == 0)
printf ("%d ", Div);
}
}

int main (void)
{
int N;

printf ("Enter a number: ");
if (scanf ("%d", &N) != 1){
exit (EXIT_FAILURE);
}
/* Okay so far */
ListProperDivs (N);

return (EXIT_SUCCESS);
}```

4. And you can loop through 1...n/2, since anything greater than n/2 is not possible.

Also the code above does not find the sum. But you can implement that easily.

5. Oops, that should teach me to read threads more carefully. But as Cshot said, it's a trivial change so I won't repost the code.

6. I don't need anyone to coding for me. i need idea of this program

7. Code:
```#include <stdio.h>
#include <stdlib.h>

void List (int N);
int N = 0;
void main (void)
{
while (N < 40)
{
N++;
printf("\n%d = ", N);
List (N);
}

}

void List (int N)
{
int Div = N;

while (--Div > 0){
if ((N % Div)== 1 )
printf ("%d ", Div);
}
}```