Let's Make Robots!


Calculate the fibonacci sequence.

As the name inplies, Fibonacci uses a basic algorithm to calculate the fibonacci sequence. It is currently running on my Basic Stamp 2, but my goal is to transfer the job to a more powerful processer, AKA my computer. The code which I used is here.


' {$STAMP BS2}

' {$PBASIC 2.5}


a VAR Word

b VAR Word

c VAR Word


a = 1

b = 1

DEBUG "1 1"


  DEBUG " "

  c = a + b


  a = b

  b = c

  PAUSE 1000




The one flaw in my system is that the highest value that a variable can be assigned is 65535, which means that the system goes back to zero when the result of two numbers exceds that value. 


UPDATE (5/18/13):

I have created the JavaScript version of the fibonacci code. Here it is:

var a = 1;

var b = 1;




c = a + b;


for (var c = 1; c < 999999999999; c = a + b)



    a = b;

    b = c;



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Oh, this is a good one...

In the Cabinet Making world, we call this guy the "Golden Ratio" and it has been indespensable in the carpentry world for hundreds of years. 1.618, yo!

If you happen to have a chest of drawers or a multi-panel door etc, you are likely to find that the dimensions of the drawers decend in size based on ol' Fibonacci. Furniture that is not built according to this Golden Ratio "looks funny".


That was my original inspiration! In class, we watched "Donald in Mathmagicland", and it covered the golden ratio. My math teacher then explained the relationship between the golden ratio and the fibonacci sequence, inspiring me to come up with the algorith at lunch.

I wonder if this is what HAL 9000 and Skynet do on thier spare time. :D

Here it is in python (I'm attaching a screen grab because I don't know how to do indents here)

And with recursion: 

Ooh, yeah!