Not able to solve pattern question in given assignment

how to make pseudocode for sum of example 3467 3+4+6+7=20 ?