All pastes #913949 Raw Edit

GG

public python v1 · immutable
·published 2008-02-22 14:11 UTC
rendered paste body
#!/usr/bin/env pythontry:	import psyco	psyco.full()except:	passdef isprime(num):	test = 3 	# Since no even number exists in the passed number.	condition = num/2 	# We store the num/2 in a variable to avoid repeated calculations of it in the loop.	while test<condition: 	# A number can at max be divided by some value the half of it,	# For instance, 15 can be at max divided by 3, and 5 but nothing above 7, which is 15/2 (Integer Division).		x = num % test		if x==0:			return 0		test+=2 		# No need to check if number is divisible by an even number so we skip to odds.	return 1	# Happens if the loop is complete with no return.		if __name__ == '__main__':	# Get the input	ip = int(raw_input("Enter the number to check: "))		# Check if input is even and accordingly call the function.	if ip == 2:		print ip, "is a prime."	elif ip&1 and isprime(ip):		print ip, "is a prime."	else:		print ip, "is not a prime."			# Obfuscated? Figure this one yourself o_O