日本語

This is program made in Python (basic 002, 003) articles in Japanese.
In order to operate it, matplotlib.pyplot, etc. need to be imported.
- Check if specific value can be divided by prime numbers less than the value.
If divided, move to next value. If not, the value is added to an array as new prime number.
- Time is obtained in the beginning and the end to calculate the time for program operation.
- Graph is shown (x: prime number, y: the number of prime number / value of prime number theory (x / ln x)).

■ Example
■ Code
import math
import time
import matplotlib.pyplot as mp

# START_NUM: start number, TRY_COUNT:numbers to be checked from start number
START_NUM = 2
TRY_COUNT = 1000000
primeNumArray = [2]
primeNumSize = [1]
primeNumSize_calc = [1]

start_time = time.time()
for var in range(START_NUM, START_NUM + TRY_COUNT):
    num = var
    flag = 1
    for var2 in primeNumArray:
        result = num % var2
        if result == 0:
            flag = 0
            break
    if flag == 1:
        print(var)
        primeNumArray.append(var)
        primeNumSize_calc.append(len(primeNumArray)/(var/math.log(var)))
        primeNumSize.append(len(primeNumArray))

mp.plot(primeNumArray, primeNumSize_calc, color="red")

end_time = time.time()
print("process_time:", len(primeNumArray), ":", end_time - start_time)
mp.grid()
mp.show()