Can python find fibonacci series in a single line of code?

Michele Simionato mis6 at pitt.edu
Tue Nov 12 10:36:29 EST 2002


a_human_work at hotmail.com (Pittaya) wrote in message news:<fa61a3d8.0211110720.16a645f8 at posting.google.com>...
> My Perl-addicted friend shows me that he can find fibanicci series in
> a single line of code.
> 
> perl -le '$b=1; print $a+=$b while print $b+=$a'
> 
> can python do something like this?

It seems that the following has not yet been proposed:

echo -e 'a,b = 1,1\nwhile a < 100: a, b = b+a, a; print a' | python

Just my $0.02,

--
Michele Simionato - Dept. of Physics and Astronomy
210 Allen Hall Pittsburgh PA 15260 U.S.A.
Phone: 001-412-624-9041 Fax: 001-412-624-9163
Home-page: http://www.phyast.pitt.edu/~micheles/



More information about the Python-list mailing list