Write a Python Program to Check Prime Number.

Write a Python Program to Check Prime Number.

Prime Numbers:

A prime number is a whole number that cannot be evenly divided by any other number except for 1 and itself. For example, 2, 3, 5, 7, 11, and 13 are prime numbers because they cannot be divided by any other positive integer except for 1 and their own value.

Program
def myfun():
    num=int(input("Enter a number: "))
    flag=False
    if(num==1):
        print(num," is not a prime number")
    elif(num>1):
        for i in range(2,num):
            if(num%i==0):
                flag=True
                break
    if flag:
        print(num," is not a prime number")
    else:
        print(num," is a prime number")
if __name__=="__main__":
    myfun()


Output:

Enter a number: 28
28 is not a prime number

Enter a number: 13
13 is a prime number



More Questions


65 . Write a Python Program to Check Leap Year.
66 . Write a Python Program to Check Prime Number.
67 . Write a Python Program to Print all Prime Numbers in an Interval of 1-10.
68 . Write a Python Program to Find the Factorial of a Number.
69 . Write a Python Program to Display the multiplication Table.
70 . Write a Python Program to Print the Fibonacci sequence.
71 . Write a Python Program to Check Armstrong Number?
72 . Write a Python Program to Find Armstrong Number in an Interval.
73 . Write a Python Program to Find the Sum of Natural Numbers.
74 . Write a Python Program to Find LCM.
75 . Write a Python Program to Find HCF.



For latest job updates join Telegram Channel: https://t.me/sateeshm