Generating Fibonacci series in Python

U

user1867151

Guest
I want to simple generate the fibonacci series in Python. But somehow i don't see the correct series. For example if i input 3 then the correct answer should come with the series : 1 1 2 3

Below is my code.Can someone please point out what is wrong with this :

def genfibonacci(no):
if no <= 1:
return no
else:
sum = genfibonacci(no - 1) + genfibonacci(no - 2)
print (sum)
return(sum)

number = int(input())
genfibonacci(number)


Thanks in advance.

Continue reading...
 
Top