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 u0 = -1 and un+1 = f(un).
Find un + un+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.