Find if x is in n the series 1, 5, 2, 13, 10, ... in the most optimal way given the fact that the series is defined by the following function: