> For the complete documentation index, see [llms.txt](https://hao-fu-1.gitbook.io/oj/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hao-fu-1.gitbook.io/oj/math/jin-zhi-zhuan-huan/660-remove-9.md).

# 660 Remove 9

把所有带9的数字移出，问第n个数会是多少。相当于原先到第10个数进位，变成现在第9个数就进位，也就是把在十进制下的n转化成没有9存在的9进制下的数。如果都是从末尾整个删去，比如remove 8和9，相当于把十进制转成8进制。如果从中间删，如删去6，相当于转成9进制后，678替换成789。

```cpp
class Solution {
public:
   int newInteger(int n) {
       int res = 0, base = 1;
       while (n > 0) {
           res += n % 9 * base;
           n /= 9;
           base *= 10;
       }
       return res;
   }
};
```
