# Fibonacci

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"

DO

DEBUG " "

c = a + b

DEBUG DEC c

a = b

b = c

PAUSE 1000

LOOP

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;

console.log("1");

console.log("1");

c = a + b;

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

{

console.log(c);

a = b;

b = c;

}

## Fibonacci!

## Python

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

## And with recursion:

And with recursion:

## I wonder if this is what HAL

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

## The golgden ratio...

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.

## Carpenters

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".

## belly buttons

You will also find that the ratio of distance from your belly button to the ground compared to the distance from your belly button to the top of your head is also a golden ratio. It keeps turning up in a lot of places.

## Computer science teacher

## A challenge

An interesting and VERY educational exercise would be to make the stamp calculate longer numbers. It is quite possible and not that hard. Every 8 bit processor (AVR/Arduino, Pic/Picaxe, Basic Stamp, etc) that calculates numbers larger than 255 does it. To get you started here is a web site that shows how to do it on the BS2.

http://emesystems.com/BS2math6.htm

## You are an evil man sir, if

You are an evil man sir, if your suggesting he does it to 64 bits. ; D

Seriously though it would be good for a 16 bit(up to 65535) attempt at least.

12next ›last »