-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (38 loc) · 968 Bytes
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from asyncio.windows_events import INFINITE
import math
def isPrime(num):
sqrt = math.floor(math.sqrt(num))
for i in range(2, sqrt + 1):
if num % i == False:
return False
return num > 1
def autoFind():
for i in range(0, INFINITE):
res = isPrime(i)
if res:
print(i, "is a prime number.")
def main():
print("What do you want to do?")
print("Select one from below =>")
print("1) Check if it's a prime number.")
print("2) Auto find prime numbers.")
sel = input()
if sel != "1" and sel != "2":
print("Invalid selection. Type either 1 or 2")
if sel == "1":
print("Provide your number")
num = input()
try:
num = int(num)
except:
print("Excepted only numbers.")
return
res = isPrime(num)
if res:
print(num, "is a prime number")
else:
print(num, "isn't a prime number")
elif sel == "2":
autoFind()
input("Press anykey and Enter to exit\n")
main()