@a5rocks/

Fast Prime Checker(Mine)

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import time
num = int(input("Test if what number is prime. (Write the number)"))
start = time.time()
checkTo = num**.5
done = False
isPrime = True
counter = 0
if round(checkTo) == checkTo:
  done = True
  isPrime = False
elif round(num) != num:
  done = True
  isPrime = False
else:
  checkTo = checkTo + 1
  while done == False:
    for x in range(2,int(checkTo)):
      if x%num == 0:
        counter = counter - 1
        isPrime = False
      counter = counter + 1
    done = True
if isPrime == False:
  print(str(num) + " is not prime.")
elif isPrime == True:
  print(str(num) + " is prime.")
end = time.time()
timeTook = end - start
print("Took " + str(timeTook) + " seconds")