Skip to content

Instantly share code, notes, and snippets.

@Obre
Created March 27, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Obre/30652c6def7f87001b6200888a399847 to your computer and use it in GitHub Desktop.
Save Obre/30652c6def7f87001b6200888a399847 to your computer and use it in GitHub Desktop.
// first approach
function fibonacci(n) {
a = 0;
b = 1;
while (a <= n) {
console.log(a);
c = a + b;
a = b;
b = c;
}
}
fibonacci(100);
// second approach
var a = 0;
var b = 1;
var n = 30;
while (a <= n) {
document.write(a + ", ");
var c = a + b;
a = b;
b = c;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment