Ugly numbers from Codeeval