Skip to main content
Code Review

Return to Question

spelling correction
Source Link

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
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

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
added 13 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

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
edited tags
Link
Mast
  • 13.8k
  • 12
  • 56
  • 127
Loading
Source Link
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /