Run
#include <stdio.h>
int main()
{
int n = 100000;
printf("\nStrong numbers in range 1 to %d :\n", n);
for(int i=1;i<=n;i++)
{
int sum = 0, digit;
int num = i;
while(num != 0)
{
digit = num % 10;
int fact = factorial(digit);
num = num/10;
sum = sum + fact;
}
if(sum == i){
printf("%d, ",i);
}
}
return 0;
}
int factorial(int n){
int mul = 1;
for(int i = 1; i <= n; i++)
mul = mul * i;
return mul;
}
#include
int main()
{
int number = 145;
int temp=number;
int product=1;
int sum=0;
while(number!=0)
{
int remainder = number % 10;
for(int i=1;i<=remainder;i++)
{
product=product*i;
}
sum=sum+product;
product=1;
number =number/10;
}
if(sum==temp)
{
printf("strong number ");
}
else{
printf("Weak numebr");
}
}
#python_code_of_strong_number
import math
num=int(input(“:”))
temp=num
sum=0
while num>0:
digit=int(num%10)
num=num//10
x=math.factorial(digit)
sum=sum+x
if temp==sum:
print(“strong number”)
else:
print(“not strong”)
# strong number
from math import factorial
num=int(input(“Enter a number : “))
temp = num
total = 0
while num > 0:
dig=num % 10
num=num//10
a=factorial(dig)
total = total + a
if total==temp:
print(f”the given number {temp} is a strong number “)
else:
print(f”the given number {temp} is not a strong number “)
Strong number for Python :
Code :-
num = int(input(“Enter a number : “))
temp = num
num = [int(d) for d in str(num)]
strng_n = 0
def fact(n):
factorial = 1
for i in range(1, n+1):
factorial = factorial * i
return factorial
for i in range(0, len(num)):
strng_n = strng_n + fact(num[i])
if temp == strng_n:
print(“It is a strong number”)
else:
print(“It is not a strong number”)
Python Solution
import math
a = int(input())
summ = 0
l = [int(d) for d in str(a)]
for i in l:
summ+=(math.factorial(i))
if summ == a:
print(“strong”)
else:
print(“not”)