/* C Program to check whether the entered number is a factorial number or not */
#include <stdio.h>
int main()
{
int num;
int flag=0;
int ctr;
printf("Enter the number\n");
scanf("%d",&num);
for(ctr=1;;ctr++)
{
if((num%ctr)!=0)
{
flag++;
break;
}
num=num/ctr;
if(num==1)
{
break;
}
}
if(flag==0)
printf("The number is a factorial of a number\n");
else
printf("The number is not a factorial of a number\n");
return 0;
}
No comments:
Post a Comment