diff --git a/README b/README index 4e3bd55..74b9643 100644 --- a/README +++ b/README @@ -1 +1,12 @@ -This just contains learner python programs. +This contains executable program to generate Fibonacci series using recursive approacch . + +The Fibonacci Sequence is the series of numbers: + +0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... + +The next number is found by adding up the two numbers before it: + +-> the 2 is found by adding the two numbers before it (1+1), +-> the 3 is found by adding the two numbers before it (1+2), +-> the 5 is (2+3), +.... and so on! diff --git a/fibo.py b/fibo.py index 4361cce..9dd7843 100644 --- a/fibo.py +++ b/fibo.py @@ -1,8 +1,9 @@ +# Fibonacci series using recursion def fib(n): # write Fibonacci series up to n - a, b = 0, 1 - while b < n: - print b, - a, b = b, a+b + if n <= 1: + return n + else: + return(fib(n-1) + fib(n-2)) def fib2(n): # return Fibonacci series up to n result = []