I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''False'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return False'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
I have updated my code from the last time it got reviewed last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
Prime number checker python3in Python 3 - follow-up
I have updated my code from the last time it got reviewed (Prime number calculator in Python 3.4.1last time it got reviewed ). If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
Prime number checker python3
I have updated my code from the last time it got reviewed (Prime number calculator in Python 3.4.1 ). If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True
Prime number checker in Python 3 - follow-up
I have updated my code from the last time it got reviewed. If anyone has some more suggestions on how I can improve this and/or make it faster it would be appreciated!
def is_prime(num):
'''Calculates whether num is a prime number,
if it is return True otherwise return Flase'''
# SPECIALCASE: These are special cases that are not primes
if num % 2 == 0 and num != 2 or num <= 1:
return False
# Look for a factor
for i in range(3, int(num ** (0.5)) + 1, 2):
# If there is a factor
if num % i == 0:
# Its not a prime number
return False
# If there is no factors and its not a special case
return True