Exemple #1
0
def test_factorial():
    print "Testing factorial "
    fails = 0
    factorials = [(5, 120), (10, 3628800), (7, 5040), (12, 479001600)]
    for f in factorials:
        if mathtools.factorial(f[0]) == f[1]:
            print '+ ',  # Pass the test
        else:
            fails += 1
            print '- ',
    if not fails:
        print "TEST OK"
    else:
        print "FOUND ", fails, " ERRORS"
Exemple #2
0
def test_factorial():
    print "Testing factorial "
    fails = 0
    factorials = [(5, 120), (10, 3628800), (7, 5040), (12, 479001600)]
    for f in factorials:
        if mathtools.factorial(f[0]) == f[1]:
            print '+ ',  # Pass the test
        else:
            fails += 1
            print '- ',
    if not fails:
        print "TEST OK"
    else:
        print "FOUND ", fails, " ERRORS"
Exemple #3
0
def num_routes(x, y):
    return factorial(x + y) / factorial(x) / factorial(y)