By Daniel · January 1, 2009
Computes the n'th number of the fibonacci sequence iteratively, taking O(n) time. This is accurate up to n=78.
/* fibonacci(n) * * Computes the n'th number of the fibonacci sequence iteratively, taking * O(n) time. This is accurate up to (and including) n=78. */ var f, i; f[0] = 0; f[1] = 1; for (i = 2; i <= argument0; i += 1) f[i] = f[i - 2] + f[i - 1]; return f[argument0];
Categories: Mathematics
There are no comments to display.
You must be signed in to post comments.