rybus / pircle

C program to draw prime numbers on a circle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plot prime numbers on a circle

Primes numbers are shown circularly with the following algorithm:

  • let n a prime number, starting at 2.

  • let displayed_prime the number of primes already on the circle

  • plot n, at the following polar coordinates:

    • r, the radius, n/20 (20 here is a zooming factor)
    • θ the angle, (n * 2 * π) / (displayed_prime - 1);
    • increase displayed_prime
    • go to next prime number following n

Screenshot

Screenshot of the program

Compile and execute

sudo apt-get install libsdl2-dev
git clone git@github.com:rybus/pircle.git
make
./main X Y
  • X is the number of primes you want to display
  • Y is the expension factor for the spiral (use 1)
  • the file primes.txt contains the list of the first million of prime numbers

Generate prime numbers

./main generate X > primes.txt

X is the number of prime numbers you want to generate.

About

C program to draw prime numbers on a circle


Languages

Language:C 92.5%Language:Makefile 5.0%Language:C++ 2.5%