Skip to content

Instantly share code, notes, and snippets.

@karlbecker
Last active January 19, 2016 23:58
Show Gist options
  • Select an option

  • Save karlbecker/2fbacf806f2116cd66c6 to your computer and use it in GitHub Desktop.

Select an option

Save karlbecker/2fbacf806f2116cd66c6 to your computer and use it in GitHub Desktop.
fib
Write an implementation of the fibonacci function.
The fibonacci function is defined as follows:
It is a function that takes one parameter, n
and returns the nth number in the fibonacci sequence.
The fibonacci sequence is the sequence of numbers,
beginning with zero and then one, where all succeeding
numbers in the sequence are the sum of the previous two
numbers.
i.e.:
n fib(n)
0 0 as defined
1 1 as defined
2 1 = 0 + 1
3 2 = 1 + 1
4 3 = 1 + 2
5 5 = 2 + 3
6 8 = 3 + 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment