На Python:
def is_prime(number):
if number <= 1:
return False
for i in range(2, number):
if number % i == 0:
if i * i > number:
break
return True
number = int(input("Enter a number: "))
if is_prime(number):
print(number, "is a prime number")
else:
print(number, "is not a prime number")
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
На Python:
def is_prime(number):
if number <= 1:
return False
for i in range(2, number):
if number % i == 0:
return False
if i * i > number:
break
return True
number = int(input("Enter a number: "))
if is_prime(number):
print(number, "is a prime number")
else:
print(number, "is not a prime number")