- Actually, the input space is much smaller than expected if we insist an
nis greater than
1691, the output overflows the
- Another way to view this bound is that all ugly numbers must be in the form
2^a*3^b*5^c. Since we have
log5(Integer.MAX_VALUE)=c<14, the combination allowed is surely under
So ugly number is sparser than one would usually think, and please do take care of overflow.
@lcn interesting observation.