I've written this code to calculate the Sylvester sequence, which is defined as $$s_n = s_{n-1}(s_{n-1}-1)+1$$ where \$s_0=2\$.
def sylvester_term(n):
""" Returns the maximum number of we will consider in a wps of dimension n
>>> sylvester_term(2)
7
>>> sylvester_term(3)
43
"""
if n == 0:
s_n = 2
return s_n
s_n = sylvester_term(n-1)*(sylvester_term(n-1)-1)+1
return s_n
print(s_n)
print(sylvester_term(3))