---
description: '# Easy'
---

# 38. Count and Say

{% hint style="info" %}
recursive, 理解题意最难，根据上一个的结果去做下一次的迭代
{% endhint %}

{% tabs %}
{% tab title="Python" %}
```python
class Solution:
    def countAndSay(self, n: int) -> str:
        result = '1'
        while n > 1:
            s = result
            result = ''
            i = 0
            while i < len(s):
                value = s[i]
                count = 0
                while i < len(s) and s[i] == value:
                    count += 1
                    i += 1
                result += str(count) + str(value)
            n -= 1
        return result
```
{% endtab %}
{% endtabs %}
