File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
36
36
19 . [ Insertion Sort] ( https://github.com/musaibbatghar/Beginners-Python-Projects/blob/main/Insertion_Sort.py ) - [ Musaib Batghar] ( https://github.com/musaibbatghar )
37
37
20 . [ Snake game] ( https://github.com/Aishanipach/Beginners-Python-Projects/compare/main...meanshkumar:Beginners-Python-Projects:main?expand=1 ) - [ Ansh Kumar] ( https://github.com/meanshkumar )
38
38
21 . [ Merge_Sort] ( https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MergeSort.py ) - [ Prateek Kumar Sahu] ( https://github.com/proPrateekSahu )
39
+
40
+ 22 . [ Fibonacci_Series] ( https://github.com/Skillz619/Beginners-Python-Projects/blob/main/fibonacci_series.py ) - [ Shreekar Kolanu] ( https://github.com/Skillz619 )
41
+
39
42
22 . [ Binary_Search] ( https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/BinarySearch ) - [ Prateek Kumar Sahu] ( https://github.com/proPrateekSahu )
40
43
23 . [ TowerOfHoni] ( https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/towerOfHoni.py ) - [ Prateek Kumar Sahu] ( https://github.com/proPrateekSahu )
41
44
24 . [ Matrix_Multiplier] ( https://github.com/proPrateekSahu/Beginners-Python-Projects/blob/main/MatrixMultiplier.py ) - [ Prateek Kumar Sahu] ( https://github.com/proPrateekSahu )
45
+
Original file line number Diff line number Diff line change
1
+ # Program to display the Fibonacci sequence up to n-th term
2
+
3
+ nterms = int (input ("How many terms? " ))
4
+
5
+ # first two terms
6
+ n1 , n2 = 0 , 1
7
+ count = 0
8
+
9
+ # check if the number of terms is valid
10
+ if nterms <= 0 :
11
+ print ("Please enter a positive integer" )
12
+
13
+ # if there is only one term, return n1
14
+ elif nterms == 1 :
15
+ print ("Fibonacci sequence upto" ,nterms ,":" )
16
+ print (n1 )
17
+
18
+ # generate fibonacci sequence
19
+ else :
20
+ print ("Fibonacci sequence:" )
21
+ while count < nterms :
22
+ print (n1 )
23
+ nth = n1 + n2
24
+ # update values
25
+ n1 = n2
26
+ n2 = nth
27
+ count += 1
You can’t perform that action at this time.
0 commit comments