Skip to content

Commit d3561d6

Browse files
authored
Merge pull request larymak#206 from lakshay451/lakshay451
Added Python Scripts for Fibonacci sequence generator
2 parents 158e56f + 29dcb2a commit d3561d6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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())
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
```

0 commit comments

Comments
 (0)