Comment Comment by maxcoder4 Can you explain your idea? Your algorithm is correct by definition, but doing this naively would be very slow (even for 32bit number). At this point it would be much faster to just binsearch it. parent maxcoder4 2 years ago