Skip to content

Instantly share code, notes, and snippets.

@yvan-sraka
Created October 26, 2016 13:54
Show Gist options
  • Save yvan-sraka/6333cc86df5362568935cb37386e4e97 to your computer and use it in GitHub Desktop.
Save yvan-sraka/6333cc86df5362568935cb37386e4e97 to your computer and use it in GitHub Desktop.
/*
* INPUT: a number N
*
* OUPUT: f(N) where f is the fibonacci function :
*
* 0 1 1 2 3 5 8 13 21 34 ..
*
* f(0) => 0
* f(1) => 1
* f(2) => 0 + 1 = 1
* f(3) => 1 + 1 = 2
* f(4) => 1 + 2 = 3
* f(5) => 2 + 3 = 5
* f(6) => 3 + 5 = 8
* f(7) => 5 + 8 = 13
* ...
*
* /!\ MATHS /!\
*
* f(0) = 0
* f(1) = 1
* f(n) = f(n - 1) + f(n - 2)
*/
function f(N) {
// PUT YOUR CODE HERE !!!
// return the Nth number of the fibonnaci sequence
}
// TEST CODE
console.log("Here 50 first fibonnaci numbers");
for (var i = 0; i < 50; ++i) {
console.log("f(" + i + ") = " + f(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment