Skip to content

Commit

Permalink
Create Python Program to Check Prime Number.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitjha9x authored Oct 10, 2022
1 parent 47eff2c commit 98b49ca
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Python Program to Check Prime Number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Program to check if a number is prime or not

num = 29

# To take input from the user
#num = int(input("Enter a number: "))

# define a flag variable
flag = False

# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break

# check if flag is True
if flag:
print(num, "is not a prime number")
else:
print(num, "is a prime number")

0 comments on commit 98b49ca

Please sign in to comment.