Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fibs = int(input("How many Fibonacci's do you want? "))
- a = [] #Create empty list
- for i in range(fibs): #Determine Fibs
- if i == 0 or i == 1: #If determining first or second, append 1
- a.append(1)
- else: #All other add the two preceding entries and append
- a.append(a[i-1] + a[i-2])
- for i in range(fibs): #Convert each list item to a string
- a[i] = str(a[i])
- print(', '.join(a)) #Join as a string with fancy seperators
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement