Answer to Question #293184 in Python for najam

Question #293184

Write a Python program that asks the user to enter an integer (X), then:


Determines if X is prime or not

If X is not prime, compute and print the factors of that integer X

Evaluate and print the equation Y=8X²+ 1, for X values from -5 to 5 using the range function and for loop


1
Expert's answer
2022-02-02T17:31:36-0500
def checkPrime(X):
  if X>1:
    for i in range(2, int(X/2)+1):
      if(X % i)==0:
        print(X, " is not a prime number\n")
        print("The factors of", X, "are: ")
        for j in range(1, X+1):
          if(X % j)==0:
            print(j," ")
         break
        else:
          print(X, " is a prime number")
    
  else:
    print(X, " is 1 or less than one and it's not prime")

X=int(input("Enter a positive Number: "))
checkPrime(X)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS