# Visualisation of the Rećaman Sequence

**URL:** https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606
**Category:** Gallery
**Created:** [May 26, 2019, 11:22am UTC](https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606 "2019-05-26T11:22:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yairkass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yairkass/32/5366_2.png) [@yairkass](https://discourse.processing.org/u/yairkass)
#### Post date: [May 26, 2019, 11:22am UTC](https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606/1 "2019-05-26T11:22:34Z")

</div>

![Rec%CC%81aman%20Spheres](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/eefda6db81354a2ca2dcde5d95a6f3cff9235dd4.jpeg)

I made a small animation sketch in Processing, visualising the properties of the Rećaman integers sequnce.

[https://oeis.org/A005132](https://oeis.org/A005132)

This is only a snapshot.  
Color represents whether a number is achieved with a jump backwards or forwards,  
Radius of the arc is the size of the jump, and rotation frequency is relative to the jump size too.  
For aesthetics reasons I used only the first 18 terms of the sequnce.

here’s the code:

```
IntList ser = new IntList();
int mxjmp = 18;
float scl = 33.0;
float rt = 0.0;
Boolean notBack;

void setup() {
  size(1500, 1000,P3D);
  strokeWeight(3);
  rectMode(CENTER);
  background(0);

  initSer();  
}

 void draw() {
   pushMatrix();
      fill(0, 10);
      noStroke();
      translate(width/2, height/2, -400);
      rect(0, 0, width*2, height*2);
    popMatrix();

for (int i=0; i<ser.size()-1; i++)
{

float yy = scl* (ser.get(i+1)+ser.get(i))/2;
float rr = scl* abs( ser.get(i+1)-ser.get(i));

noFill();
stroke(255, ser.get(i+1)-ser.get(i)>0?255:100, ser.get(i+1)-ser.get(i)>0?255:0,100);
pushMatrix();
  translate(width/2, 60);
  rotateY(rt*300/(1+i));
  arc(0, yy, rr, rr, HALF_PI+(i%2)*PI, HALF_PI+PI+(i%2)*PI);
popMatrix();
}

 rt+=0.00075;
}

void initSer() {
  int jmp = 1;
  ser = new IntList();
  ser.append(0);
  while (jmp<mxjmp)
   {
     check(ser.get(ser.size()-1)-jmp);
     if (notBack) ser.append(ser.get(ser.size()-1)+jmp); 
     else ser.append(ser.get(ser.size()-1)-jmp);
     jmp++;
   } 
}

void check(int h_) 
{
  notBack=false;
  for (int i=0; i<ser.size(); i++) 
    if (ser.get(i)==h_ || h_<0) notBack=true;
}
```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 26, 2019, 1:19pm UTC](https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606/2 "2019-05-26T13:19:02Z")

</div>

fantastic animation, looks awesome…

Congratulations!

---

<div class="post-metadata">

### Author: ![yairkass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/yairkass/32/5366_2.png) [@yairkass](https://discourse.processing.org/u/yairkass)
#### Post date: [May 26, 2019, 3:50pm UTC](https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606/3 "2019-05-26T15:50:45Z")

</div>

thanks for the kind word

---

<div class="post-metadata">

### Author: ![lfb](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@lfb](https://discourse.processing.org/u/lfb)
#### Post date: [May 26, 2019, 11:30pm UTC](https://discourse.processing.org/t/visualisation-of-the-recaman-sequence/11606/4 "2019-05-26T23:30:48Z")

</div>

Beautiful. Congrats.
