Ad

Produce 10 Fibonnaci numbers from the sequence from term n.

Example;
n=1
return [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

n=5
return [5, 8, 13, 21, 34, 55, 89, 144, 233, 377]

Code
Diff
  • def output(n):
        fib_sequence = [1, 1]
        for i in range(2, n+9):
            next_number = fib_sequence[-1] + fib_sequence[-2]
            fib_sequence.append(next_number)
        
        n-=1
        return [fib_sequence[n],fib_sequence[n+1],fib_sequence[n+2],fib_sequence[n+3],fib_sequence[n+4],fib_sequence[n+5],fib_sequence[n+6],fib_sequence[n+7],fib_sequence[n+8],fib_sequence[n+9]]
    • def output():
    • return [1, 1, 2, 3, 5, 8]
    • def output(n):
    • fib_sequence = [1, 1]
    • for i in range(2, n+9):
    • next_number = fib_sequence[-1] + fib_sequence[-2]
    • fib_sequence.append(next_number)
    • n-=1
    • return [fib_sequence[n],fib_sequence[n+1],fib_sequence[n+2],fib_sequence[n+3],fib_sequence[n+4],fib_sequence[n+5],fib_sequence[n+6],fib_sequence[n+7],fib_sequence[n+8],fib_sequence[n+9]]