Here, in Python 3, are the times to find n!, for various values of n, on my (slow) computer.
' code ------------------------------------------------------------------------------------------- # fact.py import time def fact(n): fact = 1 for i in range(1,n+1): fact *= i return fact print() print("n! seconds") for i in range(10000,210000,10000): t1 = time.clock() f = fact(i) t2 = time.clock() print("{0:06d} {1:08.3f}".format(i,t2-t1)) print() ' output ----------------------------------------------------------------------------------------- C:\Users\root\Desktop\py>python fact.py n! seconds 010000 0000.189 020000 0000.796 030000 0001.931 040000 0004.924 050000 0009.093 060000 0014.278 070000 0021.162 080000 0027.877 090000 0036.518 100000 0046.368 110000 0056.992 120000 0068.359 130000 0081.301 140000 0097.560 150000 0112.566 160000 0129.895 170000 0149.381 180000 0171.193 190000 0195.403 200000 0218.713 C:\Users\root\Desktop\py>
Bookmarks