We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f96120d commit 7f7233cCopy full SHA for 7f7233c
fibonacci/fibonacci.py
@@ -0,0 +1,41 @@
1
+#!/usr/bin/python
2
+"""
3
+Script to generate fibonacci series in python_2.7
4
5
+
6
+def fibonacci_series():
7
+ """
8
+ arguments:
9
+ ----------
10
+ none
11
12
+ returns:
13
+ --------
14
+ v: series of int
15
16
+ description:
17
+ ------------
18
+ function to return fibonacci series from 1 to n terms
19
20
+ #first and second terms
21
+ n1 = 0
22
+ n2 = 1
23
24
+ #getting number of terms
25
+ n = int(raw_input("Enter the number of terms: "))
26
+ print "Fibonacci Series: ",
27
28
+ if n == 0:
29
+ print n1
30
+ elif n == 1:
31
+ print n1,", ",n2
32
+ else:
33
+ print n1,", ",n2,", ",
34
+ for i in range(1,n):
35
+ print n2+n1,", ",
36
+ n3 = n2+n1
37
+ n1 = n2
38
+ n2 = n3
39
40
+if __name__ == "__main__":
41
+ fibonacci_series()
0 commit comments