From db15ab49edbe4ec4d6eca87a248a136c35e932b7 Mon Sep 17 00:00:00 2001 From: rajat-rg <72245885+rajat-rg@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:31:45 +0530 Subject: [PATCH 1/2] Update fibo.py updated fib() function it implements Fibonacci series using recursion --- fibo.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 = [] From 5e886149124dd6f5a2c4f62c48b4981a872c68ce Mon Sep 17 00:00:00 2001 From: rajat-rg <72245885+rajat-rg@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:35:23 +0530 Subject: [PATCH 2/2] Update README Updated README . Added introduction to Fibonacci series. --- README | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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!