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.

  1. Initialize total to 0.
  2. Use a loop to peel off each digit of num.
  3. For each digit, calculate its factorial using a second nested loop (or helper-like loop).
  4. Print "true" if the final total equals the original num, else "false".

01EXAMPLE 1

Inputnum = 145
Outputtrue

Explanation: 1! + 24 + 120 = 145.

Constraints

  • Use nested loop logic (one for digits, one for factorial).
  • No pre-calculated factorial arrays allowed.
MathLoopsDigits
JavaScript
Loading...
3 Hidden

Input Arguments

num145

Expected Output

true

Click RUN to test your solution