Last active
December 27, 2015 06:39
-
-
Save axelarge/7283473 to your computer and use it in GitHub Desktop.
In response to https://twitter.com/badcatsaver/status/396124930519339008
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
// Shortest version | |
document.write("1,2,3,5,8,13,21,34,55,89,144,233") | |
// Shortest version without cheating | |
for(a=[],x=y=1;y<301;t=x,x=y,y+=t)a.push(y);document.write(a) | |
// If it's ok to start with 1,1, this can be shortened by another char: | |
for(a=[x=y=1];y<301;t=x,x=y,y+=t)a.push(y);document.write(a) | |
// Shortest version that doesn't introduce global variables | |
for(var a=[],x=1,y=1,t;y<301;t=x,x=y,y+=t)a.push(y);document.write(a) | |
// Shortest IIFE recursive version (also no globals; could be shortened by using them, but then one might as well use one of the above) | |
(function f(a,l){var x=a[l-1]+a[l-2];x<301?f(a,a.push(x)):document.write(a)})([1,2],2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment