Strong Numbers
Submissions: 1997   Accuracy:

43.08%

  Difficulty: Basic   Marks: 1

Strong Numbers are the numbers whose sum of factorial of digits is equal to the original number. Given a number, the task is to check if it is a Strong Number or not.

Examples:

Input  : n = 145
Output : 1
Sum of digit factorials = 1! + 4! + 5!
                        = 1 + 24 + 120
                        = 145

Input :  n = 5314
Output : 0


Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow.  Each test case contains an integer N.

Output:
For each test case in a new line print 1 if the number is a strong number, else print a 0.

Constraints:
1<=T<=200
1<=N<=10000

Example:
Input:

2
145
100
Output:
1
0

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.