Loading...

Factors of number

Programme:

#include <stdio.h>

int main()
{
  int n,i;
  printf("Enter a positive integer : ");
  scanf("%d",&n);
  printf("Factors of %d are : ", n);
  for(i=1;i<=n;++i)
  {
      if(n%i==0)
         printf("%d ",i);
  }
  return 0;
}

Output:

Enter a positive integer : 32                                                                                               
Factors of 32 are : 1 2 4 8 16 32