#Python 2, 117 bytes Meh. Not that short. The simple iterative solution. <!-- language-all: lang-python --> L=[1,2,3] n=input() while len(L)<n: for i in range(2,n): if L.count(i)<L[i-1]and L[-1]!=i:L+=[i];break print L[n-1] [**Try it online**][1] Here's a really bad attempt at a recursive solution (129 bytes): def f(n,L=[1,2,3]): if len(L)>=n:print L[n-1];exit(0) for i in range(2,n): if L.count(i)<L[i-1]and L[-1]!=i:f(n,L+[i]) f(n,L) [1]: https://tio.run/nexus/python2#DclBDsIgEAXQtZxi3EFEE@oOyw3mBqQLVKoTm9@G0PT4yO4lr3GIzg72PikEwbZXbdTxlSXTkqHZjPCK5rWQkIBKwifrwcJ4dZKZ@PZad1QtZuQoVzclvIljxzmI50uIMj2eJaef2oqg9kPP1twf