Beispiel #1
0
def test_solution():
    import solution

    assert solution.factorial(1) == 1
    assert solution.factorial(2) == 2
    assert solution.factorial(5) == 120
    assert solution.factorial(10) == 3628800
# Your solution should have 'pkg' in place of 'solution' here. This simply
# reflects the different names of the directories.

import solution
print("10! = %d" % (solution.factorial(10)))
print("1 + 2 + 3 + ... + 50 = %d" % (solution.recursive_sum(list(range(51)))))
print("The first 20 elements of the fibonacci sequence:")
solution.sequences.fibonacci(20)
print("The first 20 prime numbers:")
solution.sequences.primes(20)
Beispiel #3
0
 def test_case_0(self):
     self.assertEqual(solution.factorial(3), 6)
Beispiel #4
0
def test_factorial(n, result):
    assert factorial(n) == result
Beispiel #5
0
def test_raises(n, result):
    with pytest.raises(ValueError):
        assert factorial(n)
Beispiel #6
0
def test_solution():
    assert solution.factorial(1) == 1
    assert solution.factorial(0) == 1
    assert solution.factorial(10) == 3628800
    assert solution.factorial(3) == 6
    assert solution.factorial(2) == 2