The Strong Number
MediumAcc. 87.9%
+30 XP 12
Internal Factorials
A Strong Number is a special number where the sum of the factorials of its digits equals the number itself. Example: $145 o 1! + 4! + 5! = 1 + 24 + 120 = 145$.
The Assignment
Your function receives a parameter num.
- Initialize
totalto 0. - Use a loop to peel off each digit of
num. - For each digit, calculate its factorial using a second nested loop (or helper-like loop).
- Print "true" if the final
totalequals the originalnum, else "false".
01EXAMPLE 1
Input
num = 145Output
trueExplanation: 1! + 24 + 120 = 145.
Constraints
- Use nested loop logic (one for digits, one for factorial).
- No pre-calculated factorial arrays allowed.
MathLoopsDigits
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
num145
Expected Output
true
Click RUN to test your solution