-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimaryNumber.py
More file actions
32 lines (32 loc) · 1.14 KB
/
PrimaryNumber.py
File metadata and controls
32 lines (32 loc) · 1.14 KB
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
while True:
Number = int(input()) # Read a number from the input
if Number == 2 or Number == 3:
print('prime') # If the number is 2 or 3, it is prime
continue
if Number == 1 or Number == 0:
print('not prime') # If the number is 1 or 0, it is not prime
continue
while True:
if Number % 2 == 0:
# If the number is divisible by 2, it is not prime
print('not prime')
break
else:
Counter = 2
NotPrimeFlag = 0
while True:
if Counter < Number:
Temp = Number % Counter
if Temp == 0:
NotPrimeFlag = 1
Counter = Counter + 1
if Counter == (Number - 1):
break
if NotPrimeFlag == 0:
# If the number has no divisors other than 1 and itself, it is prime
print('prime')
break
else:
# If the number has a divisor other than 1 and itself, it is not prime
print('not prime')
break