Project Euler Problem 197

# Statement

Given is the function $f(x) = int(2^{30.403243784-x^{2}}) 10^{-9}$,

the sequence un is defined by u_{0} = -1 and u_{n+1} = f(u_{n}).

Find u_{n} + u_{n+1} for n = 1012.

Give your answer with 9 digits after the decimal point.

# Solution

I computed 1000 thousand times the sequence and I saw that it stabilized in 2 alternative values. I added them and that was the answe

f_x = lambda x: int(2 ** (30.403243784 - x ** 2)) * (10 ** -9) if __name__ == '__main__': x_1 = -1 for i in range(1000): x_2 = f_x(x_1) x_1 = f_x(x_2) print("The result is:", x_1 + x_2)

The Python file is available for download here.