File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Fibonacci_Sequence_Generator Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ def Fibbo_Sequence_Generator ():
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 (Fibbo_Sequence_Generator ())
Original file line number Diff line number Diff line change 1+ # Python Fibonacci Sequence Generator
2+ This python script will ask you how many numbers do you need to see in the Fibonacci Sequence and generates the sequence based on your input.
3+
4+ ## Requirement
5+ Python 3.xx
6+
7+ ## Running the script
8+ ``` bash
9+ python Fibonacci.py
10+ ```
You can’t perform that action at this time.
0 commit comments