Given the sequence A000045 and an input parameter n, produce the Nth number in the sequence.
Various solutions for Nth Fib
import unittest | |
class TestFib(unittest.TestCase): | |
def do_test(self, fn): | |
actual = [ fn(n) for n in range(10) ] | |
expected = [ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ] | |
self.assertEqual(actual, expected) | |
def test_fib_a(self): | |
from a import fib | |
self.do_test(fib) | |
def test_fib_b(self): | |
from b import fib | |
self.do_test(fib) | |
def test_fib_c(self): | |
from c import fib | |
self.do_test(fib) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment