#!/usr/bin/env python def fib(n): ''' Simple script to test out recursive function in python. This function returns the Fibonacci number for the given argument. Copyright Yves Dorfsman 2008. This is free software ; You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ''' # validate that we don't get a non-numerical string etc... try: n = int(n) except: raise if n < 0: raise ValueError elif n == 0: p = 0 elif n == 1: p = 1 else: l = fib(n-1) m = fib(n-2) p = l + m return p import sys if __name__ == '__main__': if len(sys.argv) >= 2: f = fib(sys.argv[1]) print f else: raise ValueError