Skip to main content

Posts

Showing posts from January, 2014

wap in c to find the total number of divisors of a given number.

#include<stdio.h> #include<conio.h> #include<math.h> int arr[100000]; int prime(m,n) { int count; long int i,j,t=1,a=1; while(t--) {  if(m==1||m==2)  arr[0]=2;  if(m%2==0)  m=m+1;  for(i=m;i<=n;i=i+2)    {    count=0;    for(j=3;j<=sqrt(i);j=j+2)    if(i%j==0)    {count++;break;}   if(count==0&&i!=1)    {arr[a]=i;    a++;}    } } return(0); } main() { int divisors=1,count=0,n,i=0,j; printf("enter the number\n"); scanf("%d",&n); prime(1,n); while(n>1) {    {for(j=0;;j++)     if(n%arr[i]==0)      {n=n/arr[i];       count++;}     else     {i++;break;}      } divisors=divisors*(count+1); count=0; } printf("\nthe no of divisors is %d",divisors); getch(); } output