The Vampire Hunt
HardAcc. 70.1%
+45 XP 25
Siphoning Digits
A Vampire Number is a composite natural number with an even number of digits, that can be factored into two integers (fangs) such that:
- Both fangs have exactly half as many digits as the original.
- The fangs contain all the original digits in any order.
- Both fangs cannot end in zero simultaneously. Example: 1260 = 21 * 60.
The Assignment
Your function receives a 4-digit parameter target.
- Use nested loops to find all pairs of 2-digit factors (
x,y). - Verify if
x * y === target. - Use a logic check to ensure the digits of (
xandy) are a permutation of the digits oftarget. - Print "true" if at least one such pair exists, else "false".
01EXAMPLE 1
Input
target = 1260Output
trueExplanation: 21 * 60 = 1260. Digits match.
Constraints
- Only check 4-digit numbers.
- Digit comparison must be precise.
MathLoopsLogic
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
target1260
Expected Output
true
Click RUN to test your solution