#!/usr/bin/env python # Copyright 2005 Daniel Cer (daniel.cer@cs.colorado.edu) # # This work is licensed under the Creative Commons Attribution-NonCommercial- # ShareAlike License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to # Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, # 94105, USA. import sys def fibonacci(n): if n <= 0: return -1 if n <= 2: return 1 return fibonacci(n-1) + fibonacci(n-2) if (len(sys.argv) != 2): print >>sys.stderr, \ "Usage:\n\t",sys.argv[0]," (n-th fibonacci # to calculate)" sys.exit(-1) print "fibnacci(%s): %d" % (sys.argv[1], fibonacci(int(sys.argv[1])))