Prime Number Check
Prime Number Check
EasyBasics14% accepted
A prime number is a number greater than 1 that has no divisors other than 1 and itself. Examples: 2, 3, 5, 7, 11, 13. Given a number N, determine if it is prime. This teaches you loop optimization — you only need to check divisors up to the square root of N.
Approach
Given an integer N, print 'Prime' if N is prime, or 'Not Prime' otherwise.
Input
2
Output
YES
More Basics problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards