Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
Fibonacci Sequence
  • This program ask the user to insert the quantity of numbers from the fibonacci sequence are going to print. And as an add-on the program ask you if you wanna insert another number.

    def sequence (i):
    n = 1
    a = 0
    b = 1
    c = 0
    while n<=i:
    if n==1:
    print \"0\",
    n = n + 1
    elif n==2:
    print \"1\",
    n = n + 1
    else:
    c = a + b
    a = b
    b = c
    print c,
    n = n + 1
    continue
    r = str(\"Y\")
    while (r == \"y\")or(r==\"Y\"):
    i = input(\"Insert the quantity of numbers that you like to print \")
    sequence(i)
    print \"\"
    r = raw_input(\"You wanna insert another number Y/N \")
  • You don't need the first if N<=1, if you define "a" as 0 and "b" as 1.