NY sequence (2 points)

A new mathematical sequence was published in the New York Times newspaper in 1996. This sequence is defined as follows:

\[a_1 = 2\]
\[\begin{split}a_{i} = \begin{cases} a_{i-1} + INT[\frac{i}{2}], & \mbox{if } i \mbox{ is even, } i > 1 \\ a_{i-1} * INT[\frac{i}{2}], & \mbox{if } i \mbox{ is odd, } i > 1 \end{cases}\end{split}\]

where \(INT[x]\) means the integer part of x.

These are the first 15 items of this sequence:

2, 3, 3, 5, 10, 13, 39, 43, 172, 177, 885, 891, 5346, 5353, 37471, …

Write function nytimes() that takes a value xmax (int) and returns the first number of the previous sequence that is greater than or equal to xmax. Examples:

>>> nytimes(40)
43
>>> nytimes(10)
10
>>> nytimes(175)
177
>>> nytimes(885)
885

Note

You have more tests in file test-nytimes.txt