forked from raviprakashdev/simplePythonProgram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFibonacci.py
More file actions
23 lines (19 loc) · 703 Bytes
/
Fibonacci.py
File metadata and controls
23 lines (19 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def fibSequence():
# 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(fibSequence())