In case anyone ever wanted to know how to run the Fibonacci Sequence in Python, here’s how I did it:
#!/usr/bin/env python import sys f_seq = [ 0, 1 ] while len(f_seq) <= int(sys.argv): f_seq.append(f_seq[-1] + f_seq[-2]) print f_seq
Now, all you have to do is run
fibonacci.py 20, and it will give you all the
numbers through F20 (starting at zero).
Update: I put this up on Github, and have made a couple changes since. Check it out here!