Advertisement
Guest User

Untitled

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