Repost and improvement of this challenge from 2011
A vampire number is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller integers \$x, y\$ consisting of the digits of \$v\$ such that \$v = xy\$. For example:
$$1260 = 21 \times 60$$
so \$1260\$ is a vampire number. Note that the digits for \$v\$ can be in any order, and must be repeated for repeated digits, when splitting into \$x\$ and \$y\$. \$x\$ and \$y\$ must have the same number of digits, and only one can have trailing zeros (so \$153000\$ is not a vampire number, despite \$153000 = 300 \times 510\$).
You are to take a positive integer \$v\$ which has an even number of digits and output whether it is a vampire number or not. You can either output:
- Two consistent, distinct values
- A (not necessarily consistent) truthy value and a falsey value
- For example, "a positive integer for true, 0 for false"
You may input and output in any convenient method. This is code-golf, so the shortest code in bytes wins.
The first 15 vampire numbers are \$1260, 1395, 1435, 1530, 1827, 2187, 6880, 102510, 104260, 105210, 105264, 105750, 108135, 110758, 115672\$. This is sequence A014575 on OEIS. Be sure to double check that your solution checks for trailing zeros; \$153000\$ should return false.
n[]={1,2,6,0,1260}
? Or is it too much? I am asking because I would need a for loop with two statements just to get 1260 from its digits (or the single digits from 1260) \$\endgroup\$