#This program generates a Fibonacci series based on user input i=1 #Defines i to be zero i1=1 #Defines i1 to be 1 i2=1 #Defines i2 to be 1 i3=1 n=int(input('how many interations would you like?')) #Asks the user for integer input print(i1) #prints i1 print(i2) #prints i2 print(i3) #prints i3 while (i<=(n-2)): #does the equations i4=i1+i2+i3 #adds i1 and i2 print(i3) #prints i3 i1=i2 #changes i1 to become i2 i2=i3 #defines i2=i3 i3=i4 #defines i3=i4 i=i+1 #adds 1 to i print("all done") #prints all done
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question