Task

Find the largest base 10 integer whose digits are all different,   and   is evenly divisible by each of its individual digits.



These numbers are also known as   Lynch-Bell numbers,   numbers   n   such that the
(base ten) digits are all different (and do not include zero)   and   n   is divisible by each of its individual digits.



Example

135   is evenly divisible by   1,   3,   and   5.



Note that the digit zero (0) can not be in the number as integer division by zero is undefined.

The digits must all be unique so a base ten number will have at most 9 digits.

Feel free to use analytics and clever algorithms to reduce the search space your example needs to visit, but it must do an actual search. (Don't just feed it the answer and verify it is correct.)



Stretch goal

Do the same thing for hexadecimal.



Related tasks

   gapful numbers.
   palindromic gapful numbers. 


Also see

   The OEIS sequence:   A115569: Lynch-Bell numbers. 


s = ""
 
def uniqueDigits(i)
        global s
 
        // returns true, if unique digits, false otherwise
        for k in range(0, len(s) - 2)
                for l in range(k + 1, len(s) - 1)
                        if (s[l] = "0") || (s[l] = "5")
                                //0 or 5 digit
                                return false
                        end
 
                        if s[k] = s[l]
                                //non-unique digit
                                return false
                        end
                end
        end
 
        return true
end
 
def testNumber(i)
        global s
 
        //Tests, if i is divisible by all its digits (0 is not a digit already)
        j = 0
        divisible = true
        for ch in s
                j = int(ch)
                divisible = (i % j) = 0
                if not divisible
                        return false
                end
        end
 
        return true
end
 
i = 98764321
isUnique = true
canBeDivided = true
 
while i > 0
        s = str(i)
        isUnique = uniqueDigits(i)
        if isUnique
                //Number has unique digits
                canBeDivided = testNumber(i)
                if canBeDivided
                        println "Number found: " + i
                        i = 0
                end
        end
        i -= 1
end