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

 Print the first   25   vampire numbers and their fangs. 
 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


 
# Project : Vampire number
 
for p = 10 to 127000
     vampire(p)
next
 
func vampire(listnum)
        sum = 0
        flag = 1
        list = list(len(string(listnum)))
        total = newlist(len(list),2)
       for n = 1 to len(string(listnum))
            liststr = string(listnum)
            list[n] = liststr[n]
       next
 
       for perm = 1 to fact(len(list))
            numstr = substr(list2str(list), nl, "")
            num1 = number(left(numstr,len(numstr)/2))
            num2 = number(right(numstr,len(numstr)/2))
            if (listnum = num1 * num2)
                for n = 1 to len(total)
                     if (num1 = total[n][2] and num2 = total[n][1]) or
                         (num1 = total[n][1] and num2 = total[n][2])
                         flag = 0
                     ok
               next
               if flag = 1
                   sum = sum + 1
                   total[sum][1] = num1
                   total[sum][2] = num2                
                   see "" + listnum + ": [" + num1 + "," + num2 + "]" + nl
                ok
             ok
            nextPermutation(list)
       next
 
func nextPermutation(a)
     elementcount = len(a)
     if elementcount < 1 then return ok
     pos = elementcount-1
     while a[pos] >= a[pos+1] 
           pos -= 1
           if pos <= 0 permutationReverse(a, 1, elementcount)
              return ok
     end
     last = elementcount
     while a[last] <= a[pos]
           last -= 1
     end
     temp = a[pos]
     a[pos] = a[last]
     a[last] = temp
     permutationReverse(a, pos+1, elementcount)
 
 func permutationReverse a, first, last
      while first < last
            temp = a[first]
            a[first] = a[last]
            a[last] = temp
            first += 1
            last -= 1
      end
 
func fact(nr)
        if nr = 1 
           return 1 
        else
           return nr * fact(nr-1)
        ok
 
func newlist(x,y)
        if isstring(x) x=0+x ok
        if isstring(y) y=0+y ok
        alist = list(x)
        for t in alist
              t = list(y)
        next
        return alist
 