Given an int input n, print out n*reversed(n)
05AB1E, 2 bytes
R*
Try it online!
In 05AB1E, integers and strings are treated as equivalent types, so reversal (R
) converts to string and reverses, whilst multiplication (*
) treats the reverse and the input as integers.
JavaScript (SpiderMonkey), 45 35 33 28 bytes
n=>n*[...n].reverse().join``
Try it online!
- Saved 2 bytes thanks to dennis
- Saved 8 bytes thanks to kamoroso94
- Saved 2 bytes thanks to ATaco
- Saved 5 bytes thanks to Shaggy
Jelly, 3 bytes
×ṚḌ
I'm new to Jelly, so please let me know if there is a way to do this in 1 or 2 bytes!
Try it online!
Explanation
×ṚḌ (Input: 12)
Ṛ Reversed decimal digits (Stack: [2, 1])
× Multiply by input (Stack: [24, 12])
Ḍ Convert to decimal (Stack: 252)
Implicit print