Prime check
Write code · Basic · §2.1 Primes
Complete the function solution, which returns True if the positive integer n is prime and False otherwise.
A prime number is a number greater than 1 that is divisible only by 1 and itself.
Function
solution(n)
Constraints
nis an integer from 1 to 1,000,000,000.
Examples
| n | result |
|---|---|
7 | True |
12 | False |
Starter code
def solution(n):
answer = False
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.