MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/1zqa5t/js_fibonacci_sequence_in_48_bytes/cfwo5nc/?context=9999
r/tinycode • u/VegBerg • Mar 06 '14
function f(a,b){console.log(b);f(b,a+b);}f(0,1)
17 comments sorted by
View all comments
15
39 chars:
for(a=0,b=1;;console.log(a=(b=a+b)-a));
21 u/xNotch Mar 06 '14 36:for(a=b=1;b+=a;a=b-a)console.log(a); 24 u/Weirfish Mar 06 '14 35, you don't need the last semicolon:for(a=b=1;b+=a;a=b-a)console.log(a) 0 u/[deleted] Mar 07 '14 [deleted] 6 u/corruptio Mar 07 '14 If we're allowed to start with 1 2 instead of 0 1, then this is 33 chars:for(a=b=1;;)console.log(b+=a=b-a) 4 u/Weirfish Mar 07 '14 Fibonacci sequence technically starts with {1, 1}, I believe. 0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
21
36:
for(a=b=1;b+=a;a=b-a)console.log(a);
24 u/Weirfish Mar 06 '14 35, you don't need the last semicolon:for(a=b=1;b+=a;a=b-a)console.log(a) 0 u/[deleted] Mar 07 '14 [deleted] 6 u/corruptio Mar 07 '14 If we're allowed to start with 1 2 instead of 0 1, then this is 33 chars:for(a=b=1;;)console.log(b+=a=b-a) 4 u/Weirfish Mar 07 '14 Fibonacci sequence technically starts with {1, 1}, I believe. 0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
24
35, you don't need the last semicolon:
for(a=b=1;b+=a;a=b-a)console.log(a)
0 u/[deleted] Mar 07 '14 [deleted] 6 u/corruptio Mar 07 '14 If we're allowed to start with 1 2 instead of 0 1, then this is 33 chars:for(a=b=1;;)console.log(b+=a=b-a) 4 u/Weirfish Mar 07 '14 Fibonacci sequence technically starts with {1, 1}, I believe. 0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
0
[deleted]
6 u/corruptio Mar 07 '14 If we're allowed to start with 1 2 instead of 0 1, then this is 33 chars:for(a=b=1;;)console.log(b+=a=b-a) 4 u/Weirfish Mar 07 '14 Fibonacci sequence technically starts with {1, 1}, I believe. 0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
6
If we're allowed to start with 1 2 instead of 0 1, then this is 33 chars:
for(a=b=1;;)console.log(b+=a=b-a)
4 u/Weirfish Mar 07 '14 Fibonacci sequence technically starts with {1, 1}, I believe. 0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
4
Fibonacci sequence technically starts with {1, 1}, I believe.
0 u/[deleted] Mar 07 '14 [deleted] 1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
1 u/Weirfish Mar 07 '14 Fair enough. 34 it is.
1
Fair enough. 34 it is.
15
u/Conscars Mar 06 '14
39 chars: