Ask the user for a number and output the smallest divisor, bigger than one, for the inputted number. Output "Prime" if the number is a prime number.

num = int(input("Enter a number: ")) if num < 0: print("The number can't be less than 0.") else: div = 1 found_divisor = False while div <= num and not found_divisor: div += 1 if num % div == 0: found_divisor = True if not found_divisor or div==num: print("The number is a PRIME number.") else: print(div)

LS
Answered by Luca S. Python tutor

1119 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do I use format python code?


Write a Python script to take a product name as input and then automatically google search reviews for it and open the top 3 search results in different tabs


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


[Student query] Why do we import libraries/modules such as Numpy and Matplotlib into Python?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning