Security and Cryptography in Python - Check the performance and understand how fast the space of permutations grows

Security and Cryptography in Python - Check the performance and understand how fast the space of permutations grows

def faculty(n):
    if n <= 1:
        return n
    else:
        return faculty(n-1)*n

for i in range(10):
    print(faculty(i))

Running Result:

image-20210202200848189

import cProfile

def faculty(n):
    if n <= 1:
        return n
    else:
        return faculty(n-1)*n

def counter(n):
    cnt = 0
    for i in range(n):
        cnt += 1
    return cnt

cProfile.run("counter(faculty(10))")

Running result (n=10):

image-20210202201930880

Running result (n=11):

image-20210202202141251

Running result (n=13):

image-20210202204827760

posted @ 2021-02-02 20:23  晨风_Eric  阅读(52)  评论(0编辑  收藏  举报