Exercise 1: The number of statistics from the factorial 1-100, 1-9 to do in the first place
Python
import matplotlib.pyplot as plt def first_digital(x): while x >= 10: x //= 10 return x if __name__ == '__main__': n = 1 frequency = [0]*9 for i in range(1,100): n *= i m = first_digital(n)-1 frequency[m] += 1 print(frequency) plt.plot(frequency,'r-',linewidth=2) plt.grid(True) plt.show()
Benford's Law (Law first digital): with probability 1 as the first number that appears about 30%, three times the imaginary intuitive 1/9