This is pseudocode. I tried to calculate the time complexity of this function as this answer said. It should be like:
n + n/3 + n/9 + ... 
Maybe the time complexity is something like O(nlog(n)) I guess? Or the log(n) should be log(n) base 3? Someone said the time complexity is O(n), which is totally unacceptable for me.
j = n
while j >= 1 {
    for i = 1 to j {
        x += 1
    }
    j /= 3
}
 
     
    