The direct approach: while n≥10, extract each digit using nmod10, add them up, and repeat with the sum.
For n=38: extract 8 and 3, sum is 11. For n=11: extract 1 and 1, sum is 2. Now n<10, so return 2.
This works but takes multiple iterations. There's a faster way using modulo arithmetic.