limit, return the largest tidy number that does not exceed limit.limit=4321 → 3999
The digits of 4321 go down. The largest suitable number not above 4321 is 3999.
limit=1559 → 1559
The digits 1, 5, 5, 9 never go down, so the number itself is the answer.
limit=20 → 19
The digits of 20 go down, and the closest suitable number below it is 19.
limit=4321
3999
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.