A few years ago I was writing a web app to enter into the5k project competition. The rules of the competition was to create a functioning web app less than 5k (including external files). The app I decided to create was to generate a pattern based on a mathematical function (either the Lorenz attractor, or a spirograph) through DOM manipulation.

Whilst developing this app I created the following Javascript function that returns the nth number within the Fibonacci sequence, which I’ve recently contributed to a Wikipedia article.

function fibonacci(n)
{
var Phi=1.6180339887498948482;
var fibonacciNumber=0;
fibonacciNumber=Math.pow(Phi,n)/(Math.sqrt(5));
return Math.round(fibonacciNumber);
}

Here’s another method of calculating fibonacci(n)

function fibonacci(n)
{
var Phi=1.6180339887498948482;
var x=0;
var y=0;
var fibonacciNumber=0;
x=Math.pow(Phi,n);
y=Math.pow(-Phi,-n);
fib=(x-y)/Math.sqrt(5);
return Math.round(fibonacciNumber);
}

Example call of the above functions;

fibonacci(10)

returns the 10th number within the series which is 55.

These functions are only accurate to calculating the 70th number within the Fibonacci sequence, which is 190392490709135.

HAL9000 Desktop

October 12, 2006

Here’s a series of screenshots I’ve taken in sequence of how I recreated a recursive like effect on the cube faces of my current XGL & Beryl desktop. The process is quite simple;

  1. take a screenshot of your desktop with your preferred background image.
  2. apply this image to the top & bottom faces of the cube.
  3. rotate the cube to desired position, and take another screenshot.
  4. goto 2 and repeat.

The original image I started off with is that of the character Dave Bowman inside the central core of the HAL9000 computer, from the sci-fi classic “2001: A Space Odyssey”.
HAL9000 Desktop 1HAL9000 Desktop 2HAL9000 Desktop 3HAL9000 Desktop 4HAL9000 Desktop 5HAL9000 Desktop 6HAL9000 Desktop 7HAL9000 Desktop 8