Skip to content

Instantly share code, notes, and snippets.

@runandrerun
Created December 18, 2018 16:42
Show Gist options
  • Save runandrerun/6f41bdd13e3b2e5b897c42c8f5517a08 to your computer and use it in GitHub Desktop.
Save runandrerun/6f41bdd13e3b2e5b897c42c8f5517a08 to your computer and use it in GitHub Desktop.
function fibonacci(num){
var a = 1, b = 0, temp;
while (num >= 0){
temp = a;
a = a + b;
b = temp;
num--;
}
return b;
}
const fibonacci = (num) => {
let increment = 1;
let sum = 0;
let temporary;
while (num >= 0) {
temporary = increment;
increment = increment + sum;
sum = temporary;
num--;
};
return sum;
};
const fizzBuzz = (num) => {
for (let i = 1; i <= num; i++) {
if (i % 15 === 0) {
console.log("FizzBuzz");
} else if (i % 5 === 0) {
console.log("Fizz");
} else if (i % 3 === 0) {
console.log("Buzz");
} else {
console.log(i);
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment