eolymp
bolt
Try our new interface for solving problems
Problems

Length of S(n)

Length of S(n)

A number sequence is defined as following: \textbf{S(1)=1},\textbf{S(2)=11},\textbf{S(3)=21},\textbf{S(4)=1211},\textbf{S(5)=111221},\textbf{S(6)=312211},\textbf{……} Now, we need you to calculate the length of \textbf{S(n)}. \InputFile The input consists of multiple test cases. Each test case contains one integers \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{30}). \textbf{n = 0} signal the end of input. \OutputFile Length of \textbf{S(n)}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
5
0
Output example #1
2
6