Write a c program to check given number is strong number or not.














































Write a c program to check given number is strong number or not.



STRONG NUMBER

Definition of strong number:

A number is called strong number if sum of the factorial
of its digit is equal to number itself. For example: 145
since

1! + 4! + 5! = 1 + 24 + 120 = 145

C program to check whether the given number is strong number or not

int main()
{
	int num,i,f,r,sum=0,temp;
	printf("enter the number");
	scanf("%d",&num);
	
	temp=num;// 2. while loops are used 
	
	while(num)//1 for to take digits
	{
	i=1,f=1;
	r=num%10;
	
	while(i<=r)// another to take factorial
	{
		f=i*f;//f always 1 ,, only i is varying
		i++;
		
	}
		sum=sum+f;// link with 1st for loop
		num=num/10; // this is for 1 while loop division	
	}
	if(sum==temp)
		printf("the number %d is a strong number",temp);
	else
		printf("the number  %d is  not a strong number",temp);
}

output 1:
enter the number: 145
the number 145 is a strong number

output 2:
enter the number: 153
the number  153 is  not a strong number





Comments