Factors of a Number


Write a C program to compute factors of a given number.


#include <stdio.h>

void main()
{ 
  int n,i;
  printf("Enter the value of n whose factors are to be found:\n");
  scanf("%d",&n);
  printf("The factors are \n ");
  for(i=1;i<=n;i++)
  {   
    if(n%i==0)
     {
      printf("    %d\n",i);
     }
  }
}

Output :

Output