-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrime.py
More file actions
40 lines (32 loc) · 871 Bytes
/
Prime.py
File metadata and controls
40 lines (32 loc) · 871 Bytes
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
def prime(num):
if num > 1:
for i in range(2, num):
if num % i == 0:
return "Not Prime"
else:
return "Prime"
else:
return "Not Prime"
if __name__=="__main__":
print("Welcome to the Prime Number Program")
while True:
number = int(input("Enter Number: "))
print(f"{number} is {prime(number)}")
ch = input("Do you want to check another number? (y/n): ")
if ch.lower() != "y":
print("Thank you for using the program")
exit()
"""
Output:
Welcome to the Prime Number Program
Enter Number: 3
3 is Prime
Do you want to check another number? (y/n): y
Enter Number: 2
2 is Prime
Do you want to check another number? (y/n): y
Enter Number: 6
6 is Not Prime
Do you want to check another number? (y/n): n
Thank you for using the program
"""