GoogelAddUnit1

Friday, 26 August 2011

C program to check whether the given Number is Strong or Not.?

#include<stdio.h>
#include<conio.h>
void main()
{
int sof=0,n,dn,ctr,prod,rem;
printf("Enter the number\n");
scanf("%d",&n);
dn=n;
while(n!=0)
{
prod=1,ctr=1;
rem=n%10;
while(ctr<=rem)
{
prod=prod*ctr;
ctr=ctr+1;
}
sof=sof+prod;
n=n/10;
}
if(sof==dn)
{
printf("The number entered is strong number");
}
else
{
printf("The number entered is not a strong number");
}
}


Strong number:-
The sum of the factorials of digits of a number is equal to the original number.
Ex: n=145=> 1! + 4! + 5! = 1 + 24 + 120 = 145
so it is strong number.



No comments:

Post a Comment