コード例 #1
0
ファイル: test.py プロジェクト: smoberg/gittutorial
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"
コード例 #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"
コード例 #3
0
ファイル: pr15.py プロジェクト: pbjr23/project-euler-python
def num_routes(x, y):
    return factorial(x + y) / factorial(x) / factorial(y)