Entry 3111
Lesson1
Submitted by anonymous
on Jan. 28, 2010 at 11:54 p.m.
Language: Python. Code size: 737 bytes.
import math i = 2 print "1 is prime" raw_input() # omg cheats! print "2 is prime" raw_input() while 1 == 1: if not (i/2)*2 == i: #if odd, check if it is a prime test = 1 divisors = 0 #test values below i while i >= test: if i % test == 0: #if modulo returns zero add one to the number of divisors that returns 0 divisors =1 test =1 # if less than two divisors are zero, the number is prime! if divisors <= 2: print i,"is prime" raw_input() #so print it! i =1 #then add one to the number to test the next!
This snippet took 0.01 seconds to highlight.
Back to the Entry List or Home.