Count and Say

This sequence works like a small word game: each new term describes groups of digits from the previous one. Write a function count_and_say that returns the n-th term of the sequence. The first term is 1, and after that each run of equal digits becomes a pair: how many digits there are and which digit it is. For example, 21 becomes 1211: one 2 and one 1.

Примеры

Ввод
1
Вывод
"1"
Ввод
2
Вывод
"11"
Ввод
3
Вывод
"21"

Нужно реализовать

def count_and_say(n: int) -> str:

Теги

stringsrecursion
PostgreSQLv16

Тук ще се появи резултатът от изпълнението на кода

Visible tests
1
Input
1
Expected"1"
2
Input
2
Expected"11"
3
Input
3
Expected"21"
4
Input
4
Expected"1211"
5
Input
5
Expected"111221"
6
Input
6
Expected"312211"
Focus radio
Paused · SomaFM · Fluid