diff --git a/fibonacci_number_in_series.py b/fibonacci_number_in_series.py new file mode 100644 index 00000000..0c789a57 --- /dev/null +++ b/fibonacci_number_in_series.py @@ -0,0 +1,22 @@ +def fib(n): + phi = ((1 + (5 ** (1 / 2))) / 2); + return round((phi ** n) / (5 ** (1 / 2))); + +# Function to return the required sum +def calculateSum(l, r): + + # To store the sum + sum = 0; + + # Calculate the sum + for i in range(l, r + 1): + sum += fib(i); + + return sum; + +# Taking inputs from user +z,x = map(int,input().split()) +# Driver Code +if __name__ == '__main__': + l, r = 4, 8; + print(calculateSum(z, x));