From ecda4af98ab0f4079ee875d73dfbf895b9cc79e9 Mon Sep 17 00:00:00 2001 From: Aakash Date: Sat, 3 Oct 2020 11:53:51 +0530 Subject: [PATCH 1/2] Check a number is prime or not This program checks whether a number is prime or not --- Python/program-6/README.md | 7 +++++++ Python/program-6/program.py.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Python/program-6/README.md create mode 100644 Python/program-6/program.py.py diff --git a/Python/program-6/README.md b/Python/program-6/README.md new file mode 100644 index 00000000..8d8c46c6 --- /dev/null +++ b/Python/program-6/README.md @@ -0,0 +1,7 @@ +Program 6 + +Write a program to check whether a number is prime or not + +Variable description-- +n= holds input value + diff --git a/Python/program-6/program.py.py b/Python/program-6/program.py.py new file mode 100644 index 00000000..8b70a1d6 --- /dev/null +++ b/Python/program-6/program.py.py @@ -0,0 +1,14 @@ +n=int(input("enter any number")) +# n is the number to check whether it is prime or not +if n>1: + # loop from 2 to n/2 + for i in range(2,int(n/2)): + + if(n%i)==0: + #if n is completly divisible by i then it is not a prime number + print("n is not prime") + break + else: + print("n is prime") +else: + print("not prime") From 0dadc216abc6dc98322c4d485c22cf14f2f95cd7 Mon Sep 17 00:00:00 2001 From: Aakash Date: Sat, 3 Oct 2020 22:28:22 +0530 Subject: [PATCH 2/2] Check whether number is prime or not. --- Python/program-6/{program.py.py => program.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Python/program-6/{program.py.py => program.py} (100%) diff --git a/Python/program-6/program.py.py b/Python/program-6/program.py similarity index 100% rename from Python/program-6/program.py.py rename to Python/program-6/program.py