Entry 3469

Python isprime function

   

Submitted by anonymous on March 31, 2010 at 3:33 a.m.
Language: Python. Code size: 136 bytes.

def isprime(n):
	import math
	n = abs(n)
	i = 2
	while i <= math.sqrt(n):
		if n % i == 0:
			return False
		i += 1
	return True

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).