Where the first few instructions of SumDigits splits iValue into individual digits. A parent function makes shrinking to the smallest size optional, just call the desired function.
ReduceToSmallestSum(iValue as Integer) as Integer
Which would have the while loop that goes until the sum is one digit.
It’s not really recursion, but it’s how I’d build it – with options for myself.
While I thought about it at first (that’s a known property of mod 9), there’s an edge case: when the sum equals 9, 9 mod 9 equals 0. So, for example, 45 returns 0.
But, well, since one knows only 0 can result to 0, any result being 0 with a non-null starting number means it’s actually 9.