Mathematical Sequence Visualization

Completed: 2025-12-10

A tool for exploring and visualizing the Recamán sequence

The Recaman sequence is a mathematical sequence defined by a deceptively simple rule: start at 0, and at each step either subtract or add n, depending on whether the result has appeared yet or not. The result is a chaotic, unpredictable sequence that can be quite beautiful when represented visually.

This tool includes:

  • Animated visualization — a matplotlib animation that draws rainbow arcs as the sequence builds term by term, tracking the maximum value and the lowest values yet to appear.
  • Console logger — a high-performance version that generates millions of terms per second without rendering overhead
  • File logger + plotter — log the sequence to disk at full speed, then render the entire visualization in one pass

Some numbers are notoriously late to appear in the sequence — numbers like 1355 and 2406 take thousands of terms to finally show up. Whether every positive integer eventually appears remains an open problem in mathematics.

Technologies Used

  • Python (matplotlib, numpy)