Python program to check square root of given number is prime or not


Write a program in python to check square root of given number is prime or not 

-----------------------------------

import math
num=int(input("Enter a number "))
m=int(math.sqrt(num))
k=0
for i in range(2,m//2+1):
    if m%i==0:
        k=k+1
if k==0:
    print(m,", which is square root of ",num," , is Prime Number.")
else:
    print(m,", which is not a square root of ",num," , is not Prime Number.")

-----------------------------------

Output :

Enter a number 16

4 , which is not a square root of  16  , is not Prime Number

-----------------------------------

Enter a number 9

3 , which is square root of  9  , is Prime Number

Post a Comment

0 Comments