// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)

Project Euler Solutions

Project Euler 197 Solution

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.
Give your answer with 9 digits after the decimal point.


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.
download arrowUse this link to get the Project Euler 197 Solution Python 2.7 source.


Slowly swipe from either end beginning with the white vertical bar to get an idea of the starting or ending digits. For less drama, just double click the answer area. The distance between the two bars will give you an idea of the magnitude. Touch devices can tap and hold the center of the box between the two bars and choose define to reveal the answer.


  • 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 Graph
Project Euler 197 Solution last updated


No comments yet.

Post a comment