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.
References:#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;
}
Divisor definition: wikipedia
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...