File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ def fibSequence ():
2+ # Generates a fibonacci sequence with the size of ngi
3+ runFib = True
4+ while (runFib ):
5+ n = int (input ('How many numbers do you need? ' ))
6+ if n > 0 :
7+ runFib = False
8+ series = [1 ]
9+
10+ while len (series ) < n :
11+ if len (series ) == 1 :
12+ series .append (1 )
13+ else :
14+ series .append (series [- 1 ] + series [- 2 ])
15+
16+ for i in range (len (series )): # Convert the numbers to strings
17+ series [i ] = str (series [i ])
18+ else :
19+ print ('enter a valid number' )
20+
21+ return (', ' .join (series )) # Return the sequence seperated by commas
22+
23+ print (fibSequence ())
Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ This repo contains the following files:
44- ` Bubble Sort_2.py ` : a bubble sort program
55- ` BubbleSort.py ` : another bubble sort program
66- ` Merge Sort.py ` : a merge sort implementation program with user-received input.
7+ - ` Fibonacci.py ` : a program that takes number of digits given as input and generates a Fibonacci Sequence based on input.
78- ` README.md ` : this file
89- ` helloworld.py ` : a simple hello world program
10+ - ` greet.py ` : a simple program that requests user name and greets them with a specfic message.
911- ` spam.py ` : a simple program to give spam message to anyone
1012
1113To run spam.py install pyautogui
You can’t perform that action at this time.
0 commit comments