Substring function

S(n) is the sum of the digit substrings of n.

Example: S(123) = 1 + 2 + 3 + 12 + 23 + 123 = 164