I wrote this a few days ago and it seems to be working fine, but it is slow. It took 25 seconds to generate the 1 millionth number in the fibonacci sequence. Is there a way to make this more efficient?
def main():
num1 = 0
num2 = 1
var = 0
num = int(raw_input("What fibonacci number do you want to know? "))
while 1:
num3 = num1
num1 = num1 + num2
num2 = num3
var+=1
if var>=num:
print num3
return main()
else:
None
main()
Note that I am a beginner in python, so I won't understand advanced concepts