Skip to content

Commit 4600758

Browse files
committed
Program to find a number is prime or composite
1 parent f3bb39b commit 4600758

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
This repo consists code of all the programs discussed at http://programminginpython.com/
33

44
## List of all the programs
5-
<ul><li><a href="http://programminginpython.com/find-square-root-using-sqrt/">Find square root of a number using sqrt() function</a></li><li><a href="http://programminginpython.com/find-square-root-number-exponential-operation/">Find square root of a number using exponential operation</a></li><li><a href="http://programminginpython.com/python-program-calculate-sum-elements-list/">Python program to calculate the sum of elements in a list</a></li><li><a href="http://programminginpython.com/python-biggest-smallest-3-numbers-lists/">Python Program to find the Biggest and Smallest of 3 numbers using lists</a></li><li><a href="http://programminginpython.com/python-program-largest-smallest-number-list/">Python program to find the largest and smallest number in a list</a></li><li><a href="http://programminginpython.com/biggest-smallest-3-numbers/">Python Program to find the Biggest and Smallest of 3 numbers</a></li><li><a href="http://programminginpython.com/python-check-armstrong-number/">Python Program to check Armstrong number or not</a></li><li><a href="http://programminginpython.com/python-program-check-palindrome/">Python program to check whether a number is Palindrome or not</a></li><li><a href="http://programminginpython.com/python-program-to-find-reverse-of-a-number/">Python program to find reverse of a number</a></li><li><a href="http://programminginpython.com/find-reverse-number-slice/">Python program to find reverse of a number using slice</a></li></ul>
5+
<ul><li><a href="http://programminginpython.com/find-square-root-using-sqrt/">Find square root of a number using sqrt() function</a></li><li><a href="http://programminginpython.com/find-square-root-number-exponential-operation/">Find square root of a number using exponential operation</a></li><li><a href="http://programminginpython.com/python-program-calculate-sum-elements-list/">Python program to calculate the sum of elements in a list</a></li><li><a href="http://programminginpython.com/python-biggest-smallest-3-numbers-lists/">Python Program to find the Biggest and Smallest of 3 numbers using lists</a></li><li><a href="http://programminginpython.com/python-program-largest-smallest-number-list/">Python program to find the largest and smallest number in a list</a></li><li><a href="http://programminginpython.com/biggest-smallest-3-numbers/">Python Program to find the Biggest and Smallest of 3 numbers</a></li><li><a href="http://programminginpython.com/python-check-armstrong-number/">Python Program to check Armstrong number or not</a></li><li><a href="http://programminginpython.com/python-program-check-palindrome/">Python program to check whether a number is Palindrome or not</a></li><li><a href="http://programminginpython.com/python-program-to-find-reverse-of-a-number/">Python program to find reverse of a number</a></li><li><a href="http://programminginpython.com/find-reverse-number-slice/">Python program to find reverse of a number using slice</a></li><li><a href="http://programminginpython.com/python-program-find-number-prime-composite/">Python program to find a number is prime or composite</a></li></ul>

primeNumber.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__author__ = 'Avinash'
2+
3+
num = int(input("Enter any number : "))
4+
if num > 1:
5+
for i in range(2, num):
6+
if (num % i) == 0:
7+
print(num, "is NOT a prime number")
8+
break
9+
else:
10+
print(num, "is a PRIME number")
11+
elif num == 0 or 1:
12+
print(num, "is a neither prime NOR composite number")
13+
else:
14+
print(num, "is NOT a prime number it is a COMPOSITE number")

0 commit comments

Comments
 (0)