Last active
September 6, 2018 07:22
-
-
Save octagonal/e9111efc59c07d30ff275c609f4f218b to your computer and use it in GitHub Desktop.
Fibonacci sequence codegolf
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
// This is the shortest fib function using generators afaik | |
// Will exceed the call stack eventually | |
function fib(n) { | |
const f = function* run(a = 0, b = 1) { | |
yield a; | |
yield* run(b, a + b); | |
}(); | |
return Array(n).fill().map(()=>f.next().value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment