Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kaashmonee
Created October 19, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaashmonee/0b17b9c1e400bdbb152ab76b2230c064 to your computer and use it in GitHub Desktop.
Save kaashmonee/0b17b9c1e400bdbb152ab76b2230c064 to your computer and use it in GitHub Desktop.
#checks to see if n is prime in one line
def oneLineIsPrime(n): return False if (n % 2 == 0 and n > 2) or n < 2 or 0 in [n%factor for factor in range(3, round(n ** 0.5))] else True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment