Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions algorithms/math/fibonacci.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
def fibonacciUn(Un_2,Un_1,n):
'''
In mathematics, the Fibonacci numbers, commonly denoted Fn , form a sequence, the Fibonacci sequence, in which each number is the sum of the two preceding ones. Like for example first two terms of a sequence are 0 and 1. Now its fibonacci sequence will be as follows.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
'''

def fibonacciUn(Un_2,Un_1,n: int):
'''
This function gives two more terms
of the fibonacci sequence after
given two terms.
'''
if(n<1):
return Un_2
if (n==1):
return Un_1
for i in range(n):
fib=Un_1+Un_2
print(fib)
Un_2=Un_1
Un_1=fib
return Un_1
print(fibonacciUn(10,15,2))

fibonacciUn(10,15,2)