Skip to content

umcconnell/recaman

Repository files navigation

recaman

Visualize Recamán's sequence.

Table of Contents

About

0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, ...

Recamán's sequence (A005132 in the OIES) was invented by Bernardo Recamán. It is generated with a simple rule:

"subtract if possible, otherwise add".

Let's look at an example:

  1. We start with 0 and our step 1
  2. 0 - 1 is -1 so we add 1 and get the sequence 0, 1
  3. We increment the step by one
  4. 1 - 2 is -1 so we add 2 and get the sequence 0, 1, 3
  5. and so on...

For a good video-explanation, see The Slightly Spooky Recamán Sequence from Numberphile.

Formally, the sequence is defined as follows:

Formal definition

with a0 = 0

By drawing semi-circles to the according terms of the sequence, we receive a nice visualization:

Visualization of Recamán's Sequence

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You will need python3 and pip3 installed on your machine. You can install it from the official website https://www.python.org/. You will also need Tk support. See https://docs.python.org/3/library/tkinter.html for more information.

Initial setup

A step by step series of examples that tell you how to get a virtual python environment running:

Create your virtual environment:

python3 -m venv venv

Then activate your virtual environment:

source venv/bin/activate

To exit the virtual environment run

deactivate

Distributing

Installing

To get started, activate the virtual environment:

source venv/bin/activate

Install the packages from requirements.txt:

pip3 install -r requirements.txt

Installing additional packages

After activating the virtual environment, install your package(s)

pip3 install <package>

Then freeze your packages

pip3 freeze > requirements.txt

Contributing

Please read CONTRIBUTING.md and CODE_OF_CONDUCT.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Ulysse McConnell - umcconnell

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

See also

Acknowledgments