0

hi guys i have a proble to solve but i do not have a clue what the problem is asking me to do
i need some help.
i allready know this that a fibonacci sequence i generated by the fuction Fn=fn-1+Fn-2 but the problem says that i need to to build a program that out put F(2), F(5),F(7),F(13),and to use a loop.

I really need help I'm new at this and I do not have a clue of what the problem is asking; any help will be for sure appreciated
thanks

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by woooee
0
def fib(n):
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return a

print fib(2)
print fib(5)
print fib(7)
print fib(13)

Are you looking for that loop?

0

This is such an easy problem, I suggest you really try to understand it!

Also, a Google for "fibonacci python" has everything anyone could want. These posters are too lazy to ever make it as a programmer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.