Code
import mathdef test_for_prime(n):n = abs(n)j = 2stop=math.sqrt(n)while j <= stop:if n % j == 0:return Falsej += 1return Trueif __name__ == "__main__":print("This program determines if a number you enter is prime or not.\n")n_input = int(input("Please enter a number greater than 1: "))result=test_for_prime(n_input)if result:print(n_input, "Is prime")else:print(n_input, "is Not prime")
Output
run this code and comment the output
0 Comments
Post a Comment