Check if a number is prime

Run Settings
LanguagePython
Language Version
Run Command
num = int(input("Enter an integer:")) count = 0 for i in range(1,num+1): if num%i == 0: count+=1 if count == 2: print(num,"is a prime number.") elif num == 1: print("1 is neither prime nor composite.") elif num<0: print("Numbers less than zero are negative which cannot be prime numbers.") elif count>2: print(num,"is a composite number.") else: print("Invalid input.")
Editor Settings
Theme
Key bindings
Full width
Lines