Write a program to find the factors of a number by using function.

 Q. Write a program to find the factors of a number by using function.

Code:-

def primecheck(n):
  if n > 1:
    for i in range(2,int(n/2)+1):
      if (n % i) == 0:
        print(n,"is not a prime number.")
        break
    else:
      print(n,"is a prime number.")
  else:
    print(n,"is not a prime number.")

n = int(input("Enter a number:"))
primecheck(n)

Output:-

CASE - 1) If the user enter a negative value.



CASE - 2) If the user enter a positive value.









Comments