Finding all divisors of an integer in C

The divisor of an integer is equal to or less than that number. By definition, a divisor d integer n if and only if there is a number k such as: dk = n. For example, 5 is the divisor of 20 because 5 x 4 = 20.

In our case, we need to find all the divisors. The solution is to go through all the numbers that are less than n-1 and we decrement to 1. If the remainder of the division of n over n-i is 0 then this number is displayed. By default, any integer has at least two divisors:
  • The number itself.
  • The 1.
#include< stdio.h> 
#include< stdlib.h>

int main()
{
int number;
scanf("%d",& number);
int i;
for (i=1 ; i<=number ; i++)
{
if ((number%i)==0)
printf("%d\n",i);
}
return 0;
}
References:
Divisor definition: wikipedia