C D01 - Prime Testing - 1 Python Hackerrank

 You are given one number N. You must write a program to test whether the given number is prime or not. NOTE : A prime number is such a number that has only two factors : i.e. 1 and itself. 1 is not a prime number.

Input Format

First line contains one number, N.

Constraints

1 <= N <= 10^5

Output Format

Output "yes" if N is a prime number and "no" otherwise. (without the quotes)

Sample Input 0

5

Sample Output 0

yes

Sample Input 1

12

Sample Output 1

no
Source COde
# Enter your code here. Read input from STDIN. Print output to STDOUT
m=int(input())
if m>1:
    for i in range(2, m):
        if(m%i==0):
            print("no")
            break
    else:
        print("yes")
    
else:
    print("no")

Comments