-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-5-7 prime even.py
76 lines (67 loc) · 1.81 KB
/
4-5-7 prime even.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def number_property(n):
results = []
#checking if n is a prime number
if (n <= 1):
results.append(False)
else:
is_prime = 1
for x in range(2, n):
if (n % x == 0):
print ("x: ", x)
results.append(False)
is_prime = 0
break
if is_prime:
results.append(True)
# checking if n is even
if (n % 2 == 0):
results.append(True)
else:
results.append(False)
# checking if n is result of * 10
if (n % 10 == 0):
results.append(True)
else:
results.append(False)
return results
print (number_property(31))
print (number_property(-10)) # [False,True,True]
print (number_property(2)) # [True,True,False]
print (number_property(120)) # [False,True,True]
print (number_property(125)) # [False,False,False]
"""
def number_property(n):
results = []
if check_if_prime(n):
results.append(True)
else:
results.append(False)
if (n % 2 == 0):
results.append(True)
else:
results.append(False)
if (n % 10 == 0):
results.append(True)
else:
results.append(False)
return results
def check_if_prime(m):
if (m <= 0 or m == 1):
print (m, " is not prime number.")
return False
is_prime = 1
for x in range(2, m):
if (m % x == 0):
print (m, " is not a prime numberQQ.")
is_prime = 0
return False
break
if is_prime:
print (m, "is a prime number!")
return True
# print (number_property(31))
# print (number_property(-10)) # [False,True,True]
# print (number_property(2)) # [True,True,False]
# print (number_property(120)) # [False,True,True]
# print (number_property(125)) # [False,False,False]
"""