Write a C program to check whether given number is strong or not

C program to check whether given number is strong or not

What is Strong Number – C program start करने से पहले आपको Strong number क्या होता है पता होना चाहिए | अगर किसी number के every digit का factorial का total उस number के equal हो तो वो number strong number कहलाता है | जैसे की एक number है 145 : 1! + 4! + 5! = (1) + (1x2x3x4) + (1x2x3x4x5) = 1 + 24 + 120 = 145, so it is equal to original number इसलिए ये strong number है | 

Check whether given number is strong or not

Check whether given number is strong
or not

#include<stdio.h>

int main() {

int i,f,r,sum=0,temp,numb;

printf(“Enter a number to check: “);

scanf(“%d”,&numb);

temp=numb;

while(numb) {

i=1;

f=1;

r=numb%10;

while(i<=r) {

f=f*i;

i++;

}

sum=sum+f;

numb=numb/10;

}

if(sum==temp)

printf(“%d is strong number”,temp); else

printf(“%d is not strong number”,temp);

return 0;

}

Program Output

Enter a number to check: 145

145 is strong number

No Responses

Leave a Reply