{}
CHRISTMAS
OFFER
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
CHRISTMAS
OFFER
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
main.py
# 39. How do you check if the given number is prime? import math print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("~~~~~~~~~~~~~~~~Hello!~~~~~~~~~~~~~~~~") print("~Let's check if your number is prime.~") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") userNum = input("Please enter a number:") userNum = int(userNum) check = True if(userNum == 0 or userNum == 1): check = False elif(userNum == 2): check = True else: for i in range(2, round(math.sqrt(userNum)+1)): if(userNum % i == 0): check = False break if(check): print("\n\nYour number is prime!\n") else: print("\n\nYou number is NOT prime!\n")
Output