I am solving a problem to find out all the 4 digit Vampire numbers.

A Vampire Number v=x*y is defined as a number with 'n' even number of digits formed by multiplying a pair of 'n/2'-digit numbers (where the digits are taken from the original number in any order)x and y together. If v is a vampire number, then x&y and are called its "fangs."

Examples of vampire numbers are:

    1.    1260=21*60
    2.    1395=15*93
    3.    1530=30*51

I have tried the brute force algorithm to combine different digits of a given number and multiply them together . But this method is highly inefficient and takes up a lot of time.

Is there a more efficient algorithmic solution to this problem?

Edit
Report