Microsoft Small Basic

Program Listing: RXS942
' Reduced Sum
' Copyright © 2018 Nonki Takahashi. The MIT License.
' Challenge 2018-07

While "True"
TextWindow.Write("Number? ")
n = TextWindow.Read()
ReducedSum()
TextWindow.WriteLine(sum)
EndWhile

Sub ReducedSum
' param n
' return sum
Stack.PushValue("local", n)
len = Text.GetLength(n)
sum = n
While 1 < len
sum = 0
For p = 1 To len
sum = sum + Text.GetSubText(n, p, 1)
EndFor
len = Text.GetLength(sum)
n = sum
EndWhile
n = Stack.PopValue("local")
EndSub