The Emirp Sentinel
MediumAcc. 86.1%
+30 XP 12
Primes in the Mirror
An Emirp (prime spelled backwards) is a prime number that results in a different prime number when its digits are reversed. Example: 13 (prime) $ o$ 31 (prime). (Note: Palindromic primes like 11 are NOT emirps).
The Assignment
Your function receives a parameter target.
- Check if
targetis a prime number. - Calculate the reverse of
targetmathematically. - Check if the reverse is also a prime number.
- Check if the reverse is not equal to the original
target. - Print "true" if all conditions are met, otherwise "false".
01EXAMPLE 1
Input
target = 13Output
trueExplanation: 13 and 31 are different primes.
Constraints
- Use loops for primality and reversal.
- Explicitly exclude palindromes.
MathLoopsLogic
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
target13
Expected Output
true
Click RUN to test your solution