Fakultas Ilmu Komputer UI

prime_py.py 353 Bytes
Newer Older
Ardhi Putra Pratama's avatar
Ardhi Putra Pratama committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import time
total = 0
lower = 2
upper = 1234567

start_time = time.time();

for i in range(lower,upper):
	isprime = 1
        for j in range(2,i):
        	if (i % j == 0):
            	isprime = 0
				break


		total += isprime

elapsed_time = time.time() - start_time
print("Number of Prime Numbers = ",total)
print("Execution Time = ", elapsed_time)