Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added python script for Fibonacci sequence generator #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Fibonacci_Sequence_Generator/Fibonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def Fibbo_Sequence_Generator():
# Generates a fibonacci sequence with the size of ngi
runFib = True
while(runFib):
n = int(input('How many numbers do you need? '))
if n > 0 :
runFib = False
series = [1]

while len(series) < n:
if len(series) == 1:
series.append(1)
else:
series.append(series[-1] + series[-2])

for i in range(len(series)): # Convert the numbers to strings
series[i] = str(series[i])
else:
print('enter a valid number')

return(', '.join(series)) # Return the sequence seperated by commas

print(Fibbo_Sequence_Generator())
10 changes: 10 additions & 0 deletions Fibonacci_Sequence_Generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Python Fibonacci Sequence Generator
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.

## Requirement
Python 3.xx

## Running the script
```bash
python Fibonacci.py
```