in reply to Re^3: Golfing a fibonacci number generator
in thread Golfing a fibonacci number generator
All your numbers are all concatened together, even with perl -l. I avoided that.
Anyway, found something shorter still (42):
print$@[@@]=$@[-1]+$@[-2]for(@@=(1,0))..21
The following are my different solutions, all generating the same output under perl -l (except where noted):
sub{$_[2]=$_[0]+$_[1],print shift for 1..20}->(1,1) #51 @@=(1,1);push@@,$@[-2]+$@[-1]for 1..18;print for@@ #50 @@=(1,1);$@[2]=$@[0]+$@[1],print shift@@for 1..20 #49 @@=(1,0);print$@[@@]=$@[-1]+$@[-2]for 1..20 #43 print$@[@@]=$@[-1]+$@[-2]for(@@=(1,0))..21 #42 Missing first "1": print$@[@@]=$@[-1]+$@[-2]for(@@=1)..19 #38 Loops forever: @@=(1,0);print$@[@@]=$_+$@[-1]for@@ #35 Missing first "1" and loops forever: @@=1;print$@[@@]=$_+$@[-2]for@@ #31
|
|---|