     (6 votes, average: 5.00 out of 5) Loading...

## Project Euler 197 Solution ## Project Euler 197: Investigating the behavior of a recursively defined sequence

#### Problem Description

Given is the function f(x) = ⌊230.403243784-x2⌋ × 10-9 ( ⌊ ⌋ is the floor-function),
the sequence un is defined by u0 = -1 and un+1 = f(un).

Find un + un+1 for n = 1012.

#### Analysis

We first made a plot of this function to see what we were dealing with. It seemed to oscillate and converge very quickly bouncing back and forth between 0.6811… and 1.0294… ad infinitum. This means that instead of 1012 iterations only a few hundred are required.

#### Project Euler 197 Solution

Runs < 0.001 seconds in Python 2.7. Use this link to get the Project Euler 197 Solution Python 2.7 source.

#### Afterthoughts

• The step size of 51 was arbitrary and could be any odd number. The bigger the step size the faster the solution (fewer iterations) but the deeper the level of recursion.
• Graph of relation via Mathematica showing “ringing bell” pattern Project Euler 197 Solution last updated