[ create a new paste ] login | about

Link: http://codepad.org/3lzUfYsa    [ raw code | output | fork ]

Python, pasted on Dec 20:
1
2
3
4
5
6
7
8
9
10
11
12
13
is_Prime = 4 #Declares a variable for the number to be tested
x=is_Prime #Sets the value x to the number being tested to act as the range
counter=0 #sets a variable named counter to zero

for i in range(1,x):
    remainder = is_Prime%(x-1) #declares a variable named remainder and divides it by a value -1
    if remainder == 0:
        counter=counter+1 #if the remainder is = zero,then we add one to the counter
    x=x-1
if counter>1:
    print "number not prime"
else:
    print "number is prime"


Output:
1
number not prime


Create a new paste based on this one


Comments: