Computer Science, asked by prasenjit2004, 9 months ago

Write a program to accept a number and check whether the number is prime or not using the function int checkprime (int n).The function returns 1 if the number is a prime otherwise 0.​

Answers

Answered by yagrawal581
5

Answer:

Input

# Program to check if a number is prime or not

num = 407

# To take input from the user

#num = int(input("Enter a number: "))

# prime numbers are greater than 1

if num > 1:

# check for factors

for i in range(2,num):

if (num % i) == 0:

print(num,"is not a prime number")

print(i,"times",num//i,"is",num)

break

else:

print(num,"is a prime number")

# if input number is less than

# or equal to 1, it is not prime

else:

print(num,"is not a prime number")

Answered by bubbly1224
4

Answer:

enter a positive integer : 23

23 is also a prime number

In the above example te number entered by the user is passed to the check prime number () functions

the function returns true if the number passed to a function is prime number and return false if the number passed is not a prime number

Finally the appropriate message is printed from the main () functions

I HOPE THAT THE ANSWER IS HELPFUL FOR YOU

PLZZZZ MARK ME HAS BRAINLIEST PLZZZZZZZZZ

Attachments:
Similar questions