Problem

Source: Romania National Olympiad 2023

Tags: algebra, sum of digits



We say that a natural number is called special if all of its digits are non-zero and any two adjacent digits in its decimal representation are consecutive (not necessarily in ascending order). a) Determine the largest special number $m$ whose sum of digits is equal to $2023$. b) Determine the smallest special number $n$ whose sum of digits is equal to $2022$.