import sys from numpy import zeros #read the number of terms from command line try: N = int(sys.argv[1]) except: print('Provide the number of terms as command line argument.') sys.exit(0) x = zeros(N+1,int) """ For a second order diff eq we need to initalize the first two values:""" x[0] = 1 x[1] = 1 for n in range(2,N+1): x[n] = x[n-1]+x[n-2] print(n,x[n]) """ Terminal> python fibonacci.py 8 2 2 3 3 4 5 5 8 6 13 7 21 8 34 (Choosing N large (>90) gives overflow error. This can be solved by using another type of variable than numpy.int, but this is not very relevant in IN1900.) """