0% found this document useful (0 votes)
11 views1 page

Prime Checker

The document contains a Python script that checks if a number is prime. It uses a function that tests divisibility from 2 up to the square root of the number for efficiency. The user is prompted to input a number, and the script outputs whether it is prime or not.

Uploaded by

akashtcs2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Prime Checker

The document contains a Python script that checks if a number is prime. It uses a function that tests divisibility from 2 up to the square root of the number for efficiency. The user is prompted to input a number, and the script outputs whether it is prime or not.

Uploaded by

akashtcs2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Prime_Checker

Code:
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True

num = int(input("Enter a number: "))


print(f"{num} is prime: {is_prime(num)}")

Explanation:
This script checks whether a number is prime or not.
It iterates through potential divisors up to the square root of the number for efficiency.

You might also like