Giter Club home page Giter Club logo

recaman-sequence's Introduction

Recamán's sequence image and animation generator

Inspired by this Numberphile video, this Python 3 script generates images and animations for Recamán's sequence.

Requires matplotlib for image and animation generation and tqdm.

Usage

usage: plot.py [-h] [--start M] [--format {png,svg}] [--dpi DPI]
               [--line-width WIDTH] [--anim] [--fps FPS] [--anim-dpi DPI]
               [--degree-skip SKIP]
               N

Plot the first N numbers of the Recamán sequence

positional arguments:
  N

optional arguments:
  -h, --help          show this help message and exit
  --start M           Start the sequence with M
  --format {png,svg}  Choose a format for the plot
  --dpi DPI           Set DPI for the plot
  --line-width WIDTH  Set line width of circles
  --anim              Animate plot
  --fps FPS           Set frames per second of animation
  --anim-dpi DPI      Set DPI for the animation
  --degree-skip SKIP  Set degrees to skip in circle animation

Examples

Generate a png image of the first 100 numbers in the sequence

python plot.py 100

Plot

Generate the animation in mp4 format (ffmpeg required) with each semicircle generated 10 degrees per frame

python plot.py 100 --anim --degree-skip 10

Animation

Start argument

You can change the start number in the sequence using the --start argument. For example:

$ python recaman.py 200
[0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, ...]
$ python plot.py 200

Start at 0

$ python recaman.py 200 --start 100
[100, 99, 97, 94, 90, 85, 79, 72, 64, 55, 45, 34, 22, 9, 23, 8, 24, 7, 25, 6, 26, 5, 27, 4, 28, 3, 29, 2, 30, 1, 31, 0, 32, ...]
$ python plot.py 200 --start 100

Start at 100

License

MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.