-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrimeNumber.py
More file actions
45 lines (26 loc) · 831 Bytes
/
PrimeNumber.py
File metadata and controls
45 lines (26 loc) · 831 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
41
42
43
44
45
prime = None
num = int(input("Enter a number here to see if it is a prime number: "))
factors = []
for i in range(2, (num)):
if num%i == 0:
factors.append(str(i))
for i in range(2, (num - 1)):
if num%i != 0:
prime = ("Yes, " + str(num) + " is prime.")
else:
prime = ("No, " + str(num) + " is not prime.")
break
print(prime)
choice = input("Would you also like a list of factors for " + str(num) + " ? ")
choice = choice.upper()
if choice == "YES" or "YEAH":
if not prime == ("Yes, " + str(num) + " is prime."):
print("1,",(" ,".join(factors)), str(num))
#:>)
else:
print("1,", str(num))
elif choice == "NO" or "NO THANKS":
print("Ok then!")
else:
print("Next time, please say no or yes.")
print("Have a nice day!")