you give 0indexed integer array num numsi digit 0 9 inclusivethe triangular sum num value element present num follow process terminatesLet num comprise n element if n 1 end process otherwise create new 0indexed integer array newnums length n 1for index 0 n 1 assign value newNumsi numsi numsi1 10 denote modulo operatorreplace array num newnumsrepeat entire process start step 1return triangular sum num Example 1input num 12345output 8explanationthe diagram depict process obtain triangular sum arrayExample 2input num 5Output 5ExplanationSince element num triangular sum value element Constraints1 numslength 10000 numsi 9