Problem statement

https://binarysearch.com/problems/Repeated-Addition/

Solution

Equal to Leetcode 0258. Add Digits

Complexity

It is O(1) for time and space.

Code

class Solution:
    def solve(self, n):
        return (n - 1) % 9 + 1