Last active
December 15, 2015 19:05
-
-
Save bad6e/bba0bc827353d1ee5add to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countDown(number){ | |
if (number >= 0){ | |
console.log(number); | |
number = number - 1; | |
countDown(number); | |
} | |
} | |
countDown(5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please see attached files: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* factorialGenerator(){ | |
var count = 1; | |
var list = [1]; | |
while(true){ | |
var next = count * list[list.length-1]; | |
list.push(next); | |
yield(next); | |
count++; | |
} | |
} | |
var factorial = factorialGenerator(); | |
console.log(factorial.next().value); | |
console.log(factorial.next().value); | |
console.log(factorial.next().value); | |
console.log(factorial.next().value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fib(number) { | |
if (number === 0) { | |
return 0; | |
} else if (number === 1) { | |
return 1; | |
} else { | |
return fib(number-1)+fib(number-2); | |
} | |
} | |
function fibonacci(number){ | |
result = []; | |
for(i=1; i <= number ; i++) { | |
result.push(fib(i)); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment