SHARE
TWEET

Simple Python Primality Test

Nickster258 Nov 1st, 2016 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def isPrime(n):
  2.         if n==1: return False
  3.         if n%2==0:
  4.                 if n==2: return True
  5.                 return False
  6.         for i in range(3, math.floor(math.sqrt(n))+1, 2):
  7.                 if n%i==0: return False
  8.         return True
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top