Demo entry 5621436



Submitted by anonymous on Jul 05, 2016 at 13:18
Language: Python 3. Code size: 453 Bytes.

number=int(input('Enter a number:\t'))#gets an input from the user and saves it as number
for i in range(2,number):#every number is divisible by 1 so the loop starts at 2
    if number%i==0: # if the remainder of number/loop number is 0 the number cannot be prime
        prime=False# and so prime is set to false here

if prime==True:
    print('The number',number,'is prime.')
    print('The number',number,'is not prime.')

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).