user
A vampire number is a natural decimal number with an even number of digits,   that can be factored into two integers.

These two factors are called the   *fangs*,   and must have the following properties:

:   :   * they each contain half the number of the decimal digits of the original number
        * together they consist of exactly the same decimal digits as the original number
        * at most one of them has a trailing zero

An example of a vampire number and its fangs:    `1260 : (21, 60)`

Task

1. Print the first   **25**   vampire numbers and their fangs.
2. Check if the following numbers are vampire numbers and,   if so,   print them and their fangs:

`16758243290880, 24959017348650, 14593825548650`

Note that a vampire number can have more than one pair of fangs.

See also

* numberphile.com.
* vampire search algorithm
* vampire numbers on OEIS
assistant
(formerly Perl 6)

```
use Prime::Factor;

sub is_vampire (Int $num) {
    return Empty unless $num % 9 == 0|4;
    my $digits = $num.comb.sort;
    my @fangs;
    my @divs = $num.&divisors(:s).grep({.chars == $num.chars div 2});
    return Empty unless @divs >= 2;
    @divs.map: -> $this {
         my $that = $num div $this;
         next if $this %% 10 && $that %% 10;
         last if $this > $that;
         @fangs.push("$this x $that") if ($this ~ $that).comb.sort eq $digits;
    }
    @fangs
}

constant @vampires = flat (3..*).map: -> $s, $e {
    (flat (10**$s div 9 .. 10**$e div 9).map({my $v = $_ * 9, $v + 4})).hyper.map: -> $n {
        next unless my @fangs = is_vampire($n);
        "$n: { @fangs.join(', ') }"
    }
}

say "\nFirst 25 Vampire Numbers:\n";

.say for @vampires[^25];

say "\nIndividual tests:\n";

.say for (16758243290880, 24959017348650, 14593825548650).hyper(:1batch).map: {
    "$_: " ~ (is_vampire($_).join(', ') || 'is not a vampire number.')
}

```

```
First 25 Vampire Numbers:

1260: 21 x 60
1395: 15 x 93
1435: 35 x 41
1530: 30 x 51
1827: 21 x 87
2187: 27 x 81
6880: 80 x 86
102510: 201 x 510
104260: 260 x 401
105210: 210 x 501
105264: 204 x 516
105750: 150 x 705
108135: 135 x 801
110758: 158 x 701
115672: 152 x 761
116725: 161 x 725
117067: 167 x 701
118440: 141 x 840
120600: 201 x 600
123354: 231 x 534
124483: 281 x 443
125248: 152 x 824
125433: 231 x 543
125460: 204 x 615, 246 x 510
125500: 251 x 500

Individual tests:

16758243290880: 1982736 x 8452080, 2123856 x 7890480, 2751840 x 6089832, 2817360 x 5948208
24959017348650: 2947050 x 8469153, 2949705 x 8461530, 4125870 x 6049395, 4129587 x 6043950, 4230765 x 5899410
14593825548650: is not a vampire number.
```