Uploaded by abdulqadir42410

Write a Python

advertisement
Write a Python (or R) program that asks the user to enter an integer (X), then:
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)

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
Download