# This program computes the nth Fibonacci number def fibI(n): if n <= 1: return n else: f0, f1 = 0, 1 for i in range(2,n+1): f0, f1 = f1, f0+f1 return f1 def fibR(n): if n <= 1: return n return fibR(n-1) + fibR(n-2) def fibRE(n, f0, f1): if n == 0: return f0 if n == 1: return f1 else: return fibRE(n-1, f1, f0+f1) def main(): n = input("Enter a non -ve integer: ") print "Fib(", n, ") =", fibI(n) print "Fib(", n, ") =", fibRE(n, 0, 1) print "Fib(", n, ") =", fibR(n) main()