Recaman sequence

Hello RH/GH comunity!

I’m a beginner in using Grasshopper and I have a question:
Is it possible to define the Recamán sequence using the Expression component? Or, more basic, how do you go about when you are dealing with recursive sequences in general. What is the proper syntax or method for such situations.

The sequence in question is described here: (given as an example under the Defining a sequence by recursion section)


Grasshopper has some support for making recursive sequences (with the Sequence component) but not if the sequence requires conditional logic or looping over the entire sequence. Then it requires custom programming. Python, C#, VB, …

1 Like

Thank you for your reply David!

That is exactly what I was afraid of… :smiley:
I was hoping that there would be a workaround using something like Anemone.

Anemone may well make it possible. I don’t know enough about how it works to say one way or another.

1 Like

Here’s some C# for it… (24.8 KB)


Hi @submillimetre & @DavidRutten,

Here’s a Recamán’s Sequence GHPython script, I wrote a while back, inspired by this Numberphile video on YouTube. Apart from iteratively generating a sequence for a desired length, it also draws arc.

Feel free to check it out! :slight_smile: (7.5 KB)


Thank you so much, David! I really appreciate the time you took to help me out!
Much obliged

I can’t wait to get back home and give it a spin.

Thanks a lot! That exact same video sparked my interest regarding this particular sequence. :smiley:
As I’m trying to learn GH I took it as a nice example to crack my head with.
Although doubtful, I’ll come back to this thread if I find a “pure” GH solution. :wink:


1 Like