lucky lucky number...DOUBT


i dint understand the editorial of the given problem…can anyone please help???

Try analyzing the problem your way…
its just a simple logic!

to keep number smallest, maximize digit 4, which means maximize n’s divisibility by 7.