Skip to content

Commit 9acbda4

Browse files
authoredOct 5, 2024
Create index.py
1 parent a1cd885 commit 9acbda4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎index.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
num = 11
2+
#Negative numbers, 0 and 1 are not primes
3+
if num > 1:
4+
5+
# Iterate from 2 to n // 2
6+
for i in range(2, (num//2)+1):
7+
8+
# If num is divisible by any number between
9+
#2 and n / 2, it is not prime
10+
if (num % i) == 0:
11+
print(num, "is not a prime number")
12+
break
13+
else:
14+
print(num, "is a prime number")
15+
else:
16+
print(num, "is not a prime number")

0 commit comments

Comments
 (0)
Please sign in to comment.