Skip to content

Commit c8bd46e

Browse files
committed
V 1.0
1 parent 53fdd06 commit c8bd46e

File tree

3 files changed

+95
-26
lines changed

3 files changed

+95
-26
lines changed

CMD-Fibonacci-recursive.exe

6.87 MB
Binary file not shown.

CMD-Fibonacci-recursive.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""Python CMD program for printing Fibonacci series from 0 to input value(number_Of_Series) with a recursive function.
2+
using Python version 3.11.4
3+
@version : 1.0
4+
@license: MIT License
5+
@author : Arman Azarnik
6+
contact me at : [email protected]
7+
"""
8+
9+
def main():
10+
"""
11+
main function for interacting with the user
12+
"""
13+
while(True):
14+
# while loop to keep the program running
15+
16+
print("Please enter the number of fibonacci series :")
17+
number_Of_Series = int(input())
18+
# casting the input string into integer
19+
20+
print("Your Fibonacci serie :")
21+
result = store_Fibonacci_series_in_array(number_Of_Series)
22+
# storing Fibonacci serie array in result variable
23+
24+
array_printer(result)
25+
print("**************************************************")
26+
27+
28+
def Fibonacci_Serie_Generator_Recursive(number):
29+
"""
30+
function for generating the Fibonacci series with a recursive function.
31+
@param number: the input for serie number.
32+
@type text: int
33+
@return: Fibonacci serie number
34+
@rtype: integer
35+
@examples:
36+
>>> Fibonacci_Serie_Generator_Recursive(0)
37+
38+
>>> Fibonacci_Serie_Generator_Recursive(5)
39+
3
40+
"""
41+
if(number == 1):
42+
return 0
43+
44+
elif(number == 2):
45+
return 1
46+
47+
else:
48+
return Fibonacci_Serie_Generator_Recursive(number - 1) + Fibonacci_Serie_Generator_Recursive(number - 2)
49+
50+
51+
def store_Fibonacci_series_in_array(number):
52+
"""
53+
function for storing the generated Fibonacci serie in an array.
54+
@param number: the input for serie number.
55+
@type text: int
56+
@return: Fibonacci_Series
57+
@rtype: array of integers
58+
@examples:
59+
>>> Fibonacci_Serie_Generator_Recursive(0)
60+
[]
61+
>>> Fibonacci_Serie_Generator_Recursive(5)
62+
[0, 1, 1, 2, 3]
63+
"""
64+
Fibonacci_Series = [None]*(number)
65+
# initializing an empty array with lenght of number
66+
67+
for i in range(0, number):
68+
Fibonacci_Series[i] = Fibonacci_Serie_Generator_Recursive(i+1)
69+
# storing Fibonacci serie numbers, first number in index 0, second number in index 1 and ...
70+
71+
return Fibonacci_Series
72+
73+
74+
def array_printer(array):
75+
"""
76+
function for printing each array element in a line.
77+
@param array: an array of elements.
78+
@type text: anything like integer, double and string.
79+
@examples:
80+
array_1 = []
81+
array_2 = [1, 2, 3]
82+
>>> array_printer(array_1)
83+
84+
>>> array_printer(array_2)
85+
1
86+
2
87+
3
88+
"""
89+
for element in array:
90+
print(element)
91+
92+
93+
if __name__ == '__main__':
94+
main()
95+
# run the main function after executing this file

Fibonacci recursive.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)