Header Ads

Factor of a number

Factor of number:Factor of a number is define as the collection of numbers or 
number that when divide the number yields reminder as 0.
Example: factor of 6 is 1, 2, 3 and factor of 15 is 1, 3, 5
Number itself is not the factor of itself

#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
 int num,i;
 printf("\nEnter the number:");
 scanf("%d",&num)
 ;
 i=1;
 
 while(i<num)
 {
  if(num%i==0)
  printf("\n %d",i);
  i=i+1;
 }
 getch();
}


Output

Enter the number : 28
1
2
4
7
14_

No comments