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]
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]]
import codewars_test as test # TODO Write tests from solution import output # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(output(1), [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) test.assert_equals(output(5), [5, 8, 13, 21, 34, 55, 89, 144, 233, 377]) test.assert_equals(output(200), [280571172992510140037611932413038677189525, 453973694165307953197296969697410619233826, 734544867157818093234908902110449296423351, 1188518561323126046432205871807859915657177, 1923063428480944139667114773918309212080528, 3111581989804070186099320645726169127737705, 5034645418285014325766435419644478339818233, 8146227408089084511865756065370647467555938, 13180872826374098837632191485015125807374171, 21327100234463183349497947550385773274930109])
- import codewars_test as test
- # TODO Write tests
- from solution import output # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(output()[:6], [1, 1, 2, 3, 5, 8])- test.assert_equals(output(1), [1, 1, 2, 3, 5, 8, 13, 21, 34, 55])
- test.assert_equals(output(5), [5, 8, 13, 21, 34, 55, 89, 144, 233, 377])
- test.assert_equals(output(200), [280571172992510140037611932413038677189525, 453973694165307953197296969697410619233826, 734544867157818093234908902110449296423351, 1188518561323126046432205871807859915657177, 1923063428480944139667114773918309212080528, 3111581989804070186099320645726169127737705, 5034645418285014325766435419644478339818233, 8146227408089084511865756065370647467555938, 13180872826374098837632191485015125807374171, 21327100234463183349497947550385773274930109])