Skip to content

Commit 285b9d3

Browse files
author
John Wesley
committed
Added Fibonacci.py and updated README.md on this and another program(greet.py) of mine that got merged.
1 parent 488a241 commit 285b9d3

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Fibonacci.py

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

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

1113
To run spam.py install pyautogui

0 commit comments

Comments
 (0)