diff --git a/algorithms/math/fibonacci.py b/algorithms/math/fibonacci.py index 4420883..2324c69 100644 --- a/algorithms/math/fibonacci.py +++ b/algorithms/math/fibonacci.py @@ -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)) \ No newline at end of file + +fibonacciUn(10,15,2) \ No newline at end of file
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: