// program to illustrate strong number in between min and max values
#include<stdio.h>
void main()
{
int min,max,n,i,r,sum=0,temp,fact;
printf("\nEnter min value:");
scanf("%d",&min);
printf("\nEnter max value:");
scanf("%d",&max);
printf("\nStrong numbers are:");
for(n=min ;n<=max;n++)
{
temp=n,sum=0;
while(temp)
{
i=1,fact=1;
r=temp %10;
while(i <= r)
{
fact = fact * i;
i++;
}
sum=sum +fact;
temp = temp /10;
}
if(sum==n)
printf("\n %d is a strong number \n",n);
}
}
output:
#include<stdio.h>
void main()
{
int min,max,n,i,r,sum=0,temp,fact;
printf("\nEnter min value:");
scanf("%d",&min);
printf("\nEnter max value:");
scanf("%d",&max);
printf("\nStrong numbers are:");
for(n=min ;n<=max;n++)
{
temp=n,sum=0;
while(temp)
{
i=1,fact=1;
r=temp %10;
while(i <= r)
{
fact = fact * i;
i++;
}
sum=sum +fact;
temp = temp /10;
}
if(sum==n)
printf("\n %d is a strong number \n",n);
}
}
output:
No comments:
Post a Comment