-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprime_number.py
More file actions
36 lines (30 loc) · 1.06 KB
/
Copy pathprime_number.py
File metadata and controls
36 lines (30 loc) · 1.06 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
33
34
35
36
# Prime Number Program
# This program will allow the user to enter a number, then the program will
# determine if this number is a prime number or not. A prime number is the
# number thats divided by itself and one. Any other numbers that divided to
# more than one and itself then this numbers is not a prime numbers. for
# example 6 its divided by itself and one, pluse 2,3. so thats not a prime
# number.
def prime_num ( value ):
if value > 1:
for num in range ( 2, value):
if ( value % num ) == 0 or ( value < 1 ):
return False
else:
return True
else:
return False
def main():
# ask the user to enter a number to check if its a prime number or not
# number = int(input('Enter a number : '))
count1 = 0
count2 = 0
for i in range ( 1, 101 ):
prime = prime_num ( i )
if prime == True:
count1 += 1
else:
count2 += 1
print('Prime numbers : ', count1)
print('Not a prime number : ', count2)
main()