Ugly numbers (no memoization!)